mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: reset nopdf OCR status to pending when paper re-enters queue
This commit is contained in:
parent
ffd4eb7ca2
commit
fe36dcfe10
1 changed files with 12 additions and 1 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue