main_window: fix last digit-stem _saved_ids in _on_search_done

The primary search result handler (_on_search_done) was still using
the old filesystem walk + stem.isdigit() filter to build the saved-
post-id set. The two other call sites (_on_load_more and the
blacklist rebuild) were fixed in the earlier saved-dot sweep but
this one was missed. Templated filenames like artist_12345.jpg
were invisible, so the saved-dot disappeared after any grid
rebuild (new search, page change, etc).

Fix: use self._db.get_saved_post_ids() (one indexed SELECT,
format-agnostic) like the other two sites already do. Also drops
the saved_dir import that was only needed for the filesystem walk.
This commit is contained in:
pax 2026-04-09 19:56:55 -05:00
parent f168bece00
commit 912be0bc80

View File

@ -936,20 +936,9 @@ class BooruApp(QMainWindow):
from ..core.cache import cached_path_for, cache_dir
site_id = self._site_combo.currentData()
# Pre-scan the library once into a flat post-id set so the per-post
# check below is O(1). Folders are filesystem-truth — walk every
# subdir of saved_dir() rather than consulting the bookmark folder
# list (which used to leak DB state into library detection).
_sd = saved_dir()
_saved_ids: set[int] = set()
if _sd.is_dir():
for entry in _sd.iterdir():
if entry.is_file() and entry.stem.isdigit():
_saved_ids.add(int(entry.stem))
elif entry.is_dir():
for sub in entry.iterdir():
if sub.is_file() and sub.stem.isdigit():
_saved_ids.add(int(sub.stem))
# library_meta-driven saved-id set: format-agnostic, covers both
# digit-stem v0.2.3 files and templated post-refactor saves.
_saved_ids = self._db.get_saved_post_ids()
# Pre-fetch bookmarks for the site once and project to a post-id set
# so the per-post check below is an O(1) membership test instead of