library: fix tag search for templated filenames
The tag search filter in refresh() used f.stem.isdigit() to extract post_id — templated filenames like artist_12345.jpg failed the check and got filtered out even when their post_id matched the search query. Fix: look up post_id via db.get_library_post_id_by_filename first (handles templated filenames), fall back to int(stem) for legacy digit-stem files. Same pattern as the delete and saved-dot fixes from earlier in this refactor.
This commit is contained in:
parent
c02cc4fc38
commit
64f0096f32
@ -158,7 +158,16 @@ class LibraryView(QWidget):
|
|||||||
if query and self._db:
|
if query and self._db:
|
||||||
matching_ids = self._db.search_library_meta(query)
|
matching_ids = self._db.search_library_meta(query)
|
||||||
if matching_ids:
|
if matching_ids:
|
||||||
self._files = [f for f in self._files if f.stem.isdigit() and int(f.stem) in matching_ids]
|
def _file_matches(f: Path) -> bool:
|
||||||
|
# Templated filenames: look up post_id via library_meta.filename
|
||||||
|
pid = self._db.get_library_post_id_by_filename(f.name)
|
||||||
|
if pid is not None:
|
||||||
|
return pid in matching_ids
|
||||||
|
# Legacy digit-stem fallback
|
||||||
|
if f.stem.isdigit():
|
||||||
|
return int(f.stem) in matching_ids
|
||||||
|
return False
|
||||||
|
self._files = [f for f in self._files if _file_matches(f)]
|
||||||
else:
|
else:
|
||||||
self._files = []
|
self._files = []
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user