From 912be0bc8034cf31b05fa3b1d9dff2ec2ef4303a Mon Sep 17 00:00:00 2001 From: pax Date: Thu, 9 Apr 2026 19:56:55 -0500 Subject: [PATCH] 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. --- booru_viewer/gui/main_window.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/booru_viewer/gui/main_window.py b/booru_viewer/gui/main_window.py index d15f278..656ba3b 100644 --- a/booru_viewer/gui/main_window.py +++ b/booru_viewer/gui/main_window.py @@ -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