From fe36dcfe10d8f7d3601a62e4fddb16c20c19e15c Mon Sep 17 00:00:00 2001 From: Research Assistant Date: Thu, 14 May 2026 18:43:48 +0800 Subject: [PATCH] fix: reset nopdf OCR status to pending when paper re-enters queue --- paperforge/worker/ocr.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/paperforge/worker/ocr.py b/paperforge/worker/ocr.py index e01d4e2e..3bf54ee4 100644 --- a/paperforge/worker/ocr.py +++ b/paperforge/worker/ocr.py @@ -190,6 +190,8 @@ def sync_ocr_queue(paths: dict[str, Path], target_rows: list[dict]) -> list[dict status = str(meta.get("ocr_status", "pending") or "pending").strip().lower() if status in {"done", "blocked"}: continue + if status == "nopdf": + status = "pending" synced = dict(row) synced["has_pdf"] = bool(target.get("has_pdf")) synced["pdf_path"] = target.get("pdf_path", "") @@ -210,6 +212,9 @@ def sync_ocr_queue(paths: dict[str, Path], target_rows: list[dict]) -> list[dict status = str(meta.get("ocr_status", "pending") or "pending").strip().lower() if status in {"done", "blocked"}: continue + if status == "nopdf": + status = "pending" + continue synced_queue.append( { "zotero_key": key, @@ -1571,13 +1576,19 @@ def run_ocr(vault: Path, verbose: bool = False, no_progress: bool = False) -> in for row in target_rows: key = row["zotero_key"] meta = ensure_ocr_meta(vault, row) - if str(meta.get("ocr_status", "") or "").strip().lower() == "error": + current = str(meta.get("ocr_status", "") or "").strip().lower() + if current == "error": meta["ocr_status"] = "pending" meta["ocr_job_id"] = "" meta["ocr_started_at"] = "" meta["ocr_finished_at"] = "" meta["retry_count"] = 0 write_json(paths["ocr"] / key / "meta.json", meta) + elif current == "nopdf": + meta["ocr_status"] = "pending" + meta["error"] = "" + meta["retry_count"] = 0 + write_json(paths["ocr"] / key / "meta.json", meta) status, _error = validate_ocr_meta(paths, meta) if status == "done_incomplete": meta["ocr_status"] = "pending"