From 6c767e2427bca7080b8957bb7f5f98d507a73872 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 22 Apr 2026 15:45:47 -0400 Subject: [PATCH] refactor(importer): archive tags drop kind prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Archive identifier string (artist:archive_name) stays as the tag's opaque name — the archive kind lives in the kind column. Co-Authored-By: Claude Opus 4.7 --- app/utils/image_importer.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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)