From 119c62394efade6d80b73d1ab91b928f69eb3ff2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Jan 2026 22:57:03 +0530 Subject: [PATCH] Allow pages_needs_scan to work with all books easily --- src/calibre/db/cache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 53311e57d5..5f215ecc7f 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -1756,9 +1756,11 @@ class Cache: return Pages(int(pages), int(algorithm), str(format), int(format_size), parse_iso8601(timestamp, assume_utc=True)) @read_api - def pages_needs_scan(self, books: Iterable[int]) -> set[int]: - ' Return the subset of books that are marked as needing a scan to update page count ' + def pages_needs_scan(self, books: Iterable[int] = ()) -> set[int]: + ' Return the subset of books (or all books if empty) that are marked as needing a scan to update page count ' books = tuple(books) + if not books: + return {r[0] for r in self.backend.execute('SELECT book FROM books_pages_link WHERE needs_scan=1')} ans = set() BATCH_SIZE = self.backend.max_number_of_variables for i in range(0, len(books), BATCH_SIZE):