From 52b76dfc83e58e30aeb7065a7a5ac3d32a8e323a Mon Sep 17 00:00:00 2001 From: pax Date: Sat, 11 Apr 2026 21:57:18 -0500 Subject: [PATCH] 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. --- booru_viewer/gui/library.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/booru_viewer/gui/library.py b/booru_viewer/gui/library.py index bbe04c1..a8b06f1 100644 --- a/booru_viewer/gui/library.py +++ b/booru_viewer/gui/library.py @@ -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)