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:
parent
f168bece00
commit
912be0bc80
@ -936,20 +936,9 @@ class BooruApp(QMainWindow):
|
|||||||
from ..core.cache import cached_path_for, cache_dir
|
from ..core.cache import cached_path_for, cache_dir
|
||||||
site_id = self._site_combo.currentData()
|
site_id = self._site_combo.currentData()
|
||||||
|
|
||||||
# Pre-scan the library once into a flat post-id set so the per-post
|
# library_meta-driven saved-id set: format-agnostic, covers both
|
||||||
# check below is O(1). Folders are filesystem-truth — walk every
|
# digit-stem v0.2.3 files and templated post-refactor saves.
|
||||||
# subdir of saved_dir() rather than consulting the bookmark folder
|
_saved_ids = self._db.get_saved_post_ids()
|
||||||
# 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))
|
|
||||||
|
|
||||||
# Pre-fetch bookmarks for the site once and project to a post-id set
|
# 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
|
# so the per-post check below is an O(1) membership test instead of
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user