diff --git a/app/utils/image_importer.py b/app/utils/image_importer.py index f025ac3..9b4b547 100644 --- a/app/utils/image_importer.py +++ b/app/utils/image_importer.py @@ -946,30 +946,30 @@ def extract_archive_name(filename: str) -> str: def compute_archive_tag_name(artist: str, archive_filename: str) -> str: """ - Generate an archive tag name in the format: 'archive:{artist}:{archive_name}' + Generate an archive tag name in the format: '{artist}:{archive_name}' Similar to post tags (post:{platform}:{artist}:{id}), archive tags use a consistent prefix and colon-separated components. Examples: - artist="InCaseArt", filename="43387617_attachment_83109081_October 2020 Rewards.rar" - -> "archive:InCaseArt:October 2020 Rewards" + -> "InCaseArt:October 2020 Rewards" If a tag with the same name already exists, appends a numeric suffix. """ archive_name = extract_archive_name(archive_filename) - base_tag = f"archive:{artist}:{archive_name}" + base_name = f"{artist}:{archive_name}" # Check if tag already exists - existing = Tag.query.filter_by(name=base_tag, kind='archive').first() + existing = Tag.query.filter_by(kind='archive', name=base_name).first() if not existing: - return base_tag + return base_name # Tag exists, add numeric suffix n = 2 while True: - candidate = f"{base_tag} ({n})" - if not Tag.query.filter_by(name=candidate, kind='archive').first(): + candidate = f"{base_name} ({n})" + if not Tag.query.filter_by(kind='archive', name=candidate).first(): return candidate n += 1 @@ -978,12 +978,12 @@ def compute_next_archive_tag_name(artist: str, width: int = ARCHIVE_NUM_WIDTH) - """ DEPRECATED: Use compute_archive_tag_name() instead. - Return a unique incremental tag name like: 'archive:{artist}/0001', '0002', ... - - Looks only at Tag(kind='archive') with names starting 'archive:{artist}/' + Return a unique incremental tag name like: '{artist}/0001', '0002', ... + - Looks only at Tag(kind='archive') with names starting '{artist}/' - Finds max numeric suffix and returns next number (zero-padded). - Ensures no collision even if tags were renamed. """ - prefix = f"archive:{artist}/" + prefix = f"{artist}/" # Pull existing tag names for this artist/prefix rows = (Tag.query .with_entities(Tag.name)