ui polish and importer logging tuning

This commit is contained in:
Bryan Van Deusen
2026-01-28 09:36:59 -05:00
parent 0bf1961175
commit d0fcde38e8
12 changed files with 110 additions and 133 deletions
+3 -34
View File
@@ -6,6 +6,7 @@ from datetime import datetime
from pathlib import Path
import hashlib
import json
import logging
import mimetypes
import os
import re
@@ -14,6 +15,8 @@ import subprocess
import tempfile
import uuid
log = logging.getLogger(__name__)
from PIL import Image, ImageOps
import exifread
import imagehash
@@ -843,40 +846,6 @@ def is_first_volume(path: str) -> bool:
return True
def compute_next_archive_tag_name(artist: str, width: int = ARCHIVE_NUM_WIDTH) -> str:
"""
Return a unique incremental tag name like: 'archive:{artist}/0001', '0002', ...
- Looks only at Tag(kind='archive') with names starting 'archive:{artist}/'
- Finds max numeric suffix and returns next number (zero-padded).
- Ensures no collision even if tags were renamed.
"""
prefix = f"archive:{artist}/"
# Pull existing tag names for this artist/prefix
rows = (Tag.query
.with_entities(Tag.name)
.filter(Tag.kind == 'archive',
Tag.name.like(prefix + '%'))
.all())
max_n = 0
for (name,) in rows:
tail = name[len(prefix):]
if tail.isdigit():
try:
n = int(tail)
if n > max_n:
max_n = n
except Exception:
pass
# Propose next number and make sure it doesn't already exist
n = max_n + 1
while True:
candidate = f"{prefix}{str(n).zfill(width)}"
if not Tag.query.filter_by(name=candidate).first():
return candidate
n += 1
def compute_next_archive_tag_name(artist: str, width: int = ARCHIVE_NUM_WIDTH) -> str:
"""
Return a unique incremental tag name like: 'archive:{artist}/0001', '0002', ...