library: fix thumbnail cleanup for templated filenames

Single-delete and multi-delete used filepath.stem for the thumbnail
path, but library thumbnails are keyed by post_id. Templated filenames
like artist_12345.jpg would look for thumbnails/library/artist_12345.jpg
instead of thumbnails/library/12345.jpg, leaving orphan thumbnails.

Now uses the resolved post_id when available, falls back to stem for
legacy digit-stem files.
This commit is contained in:
pax 2026-04-11 21:57:18 -05:00
parent c210c4b44a
commit 52b76dfc83

View File

@ -520,7 +520,8 @@ class LibraryView(QWidget):
if post_id is None and filepath.stem.isdigit():
post_id = int(filepath.stem)
filepath.unlink(missing_ok=True)
lib_thumb = thumbnails_dir() / "library" / f"{filepath.stem}.jpg"
thumb_key = str(post_id) if post_id is not None else filepath.stem
lib_thumb = thumbnails_dir() / "library" / f"{thumb_key}.jpg"
lib_thumb.unlink(missing_ok=True)
if post_id is not None:
self._db.remove_library_meta(post_id)
@ -575,7 +576,8 @@ class LibraryView(QWidget):
if post_id is None and f.stem.isdigit():
post_id = int(f.stem)
f.unlink(missing_ok=True)
lib_thumb = thumbnails_dir() / "library" / f"{f.stem}.jpg"
thumb_key = str(post_id) if post_id is not None else f.stem
lib_thumb = thumbnails_dir() / "library" / f"{thumb_key}.jpg"
lib_thumb.unlink(missing_ok=True)
if post_id is not None:
self._db.remove_library_meta(post_id)