From 634bb31f245473e00fc578b768b384214c94d32a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Aug 2022 10:47:04 +0530 Subject: [PATCH] Fix FTS indexing not progressing when dirtied books have no actual changes --- src/calibre/db/cache.py | 4 +++- src/calibre/db/fts/pool.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 839854e672..eb928efe2b 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -520,7 +520,9 @@ class Cache: h.update(chunk) pt.write(chunk) with self.write_lock: - self.backend.queue_fts_job(book_id, fmt, pt.name, sz, h.hexdigest()) + queued = self.backend.queue_fts_job(book_id, fmt, pt.name, sz, h.hexdigest()) + if not queued: # means a dirtied book was removed + self._update_fts_indexing_numbers() return self.backend.fts_has_idle_workers def loop_while_more_available(): diff --git a/src/calibre/db/fts/pool.py b/src/calibre/db/fts/pool.py index e7dbeb8fab..995a55c265 100644 --- a/src/calibre/db/fts/pool.py +++ b/src/calibre/db/fts/pool.py @@ -171,7 +171,7 @@ class Pool: @property def num_of_idle_workers(self): - return sum(1 if w.working else 0 for w in self.workers) + return sum(0 if w.working else 1 for w in self.workers) def check_for_work(self): self.initialize()