library: fix thumbnail lookup for templated filenames
Library thumbnails are saved by post_id (_copy_library_thumb uses
f"{post.id}.jpg") but the library viewer looked them up by file
stem (f"{filepath.stem}.jpg"). For digit-stem files (12345.jpg)
these are the same. For templated files (artist_12345.jpg) the
stem is "artist_12345" which doesn't match the thumbnail named
"12345.jpg" — wrong or missing thumbnails.
Fix: resolve post_id from the filename via
get_library_post_id_by_filename, then look up the thumbnail as
f"{post_id}.jpg". Generated thumbnails (for files without a
cached browse thumbnail) also store by post_id now, so
everything stays consistent.
This commit is contained in:
parent
64f0096f32
commit
31089adf7d
@ -189,7 +189,17 @@ class LibraryView(QWidget):
|
|||||||
thumb._cached_path = str(filepath)
|
thumb._cached_path = str(filepath)
|
||||||
thumb.setToolTip(filepath.name)
|
thumb.setToolTip(filepath.name)
|
||||||
thumb.set_saved_locally(True)
|
thumb.set_saved_locally(True)
|
||||||
cached_thumb = lib_thumb_dir / f"{filepath.stem}.jpg"
|
# Thumbnails are stored by post_id (from _copy_library_thumb),
|
||||||
|
# not by filename stem. Resolve post_id so templated filenames
|
||||||
|
# like artist_12345.jpg find their thumbnail correctly.
|
||||||
|
thumb_name = filepath.stem # default: digit-stem fallback
|
||||||
|
if self._db:
|
||||||
|
pid = self._db.get_library_post_id_by_filename(filepath.name)
|
||||||
|
if pid is not None:
|
||||||
|
thumb_name = str(pid)
|
||||||
|
elif filepath.stem.isdigit():
|
||||||
|
thumb_name = filepath.stem
|
||||||
|
cached_thumb = lib_thumb_dir / f"{thumb_name}.jpg"
|
||||||
if cached_thumb.exists():
|
if cached_thumb.exists():
|
||||||
pix = QPixmap(str(cached_thumb))
|
pix = QPixmap(str(cached_thumb))
|
||||||
if not pix.isNull():
|
if not pix.isNull():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user