check for doubles

This commit is contained in:
2026-05-12 15:02:45 +02:00
parent 3ee5b0c24d
commit f726174648
2 changed files with 32 additions and 4 deletions
+8
View File
@@ -64,6 +64,14 @@ def run_sync(limit: int | None = None) -> None:
total_batches = -(-len(new_zips) // batch_size) # ceiling division
client = CalibreClient(cfg.calibre)
# Pre-load existing book titles so duplicate detection doesn't need per-book OPDS searches
try:
from uploader import fetch_all_books
existing = fetch_all_books(cfg.calibre)
client.preload_existing_titles(existing)
except Exception as exc:
log.warning("Could not pre-load existing books (%s) — will fall back to per-book OPDS search", exc)
for batch_num, i in enumerate(range(0, len(new_zips), batch_size), start=1):
chunk = new_zips[i : i + batch_size]
log.info("Batch %d/%d — processing %d zip(s)", batch_num, total_batches, len(chunk))