sync errors

This commit is contained in:
2026-05-10 21:06:33 +02:00
parent dfc9fa3800
commit 877c4c9d67
2 changed files with 31 additions and 9 deletions
+7 -1
View File
@@ -7,7 +7,7 @@ import config
import db
import extractor
import sftp as sftp_module
from uploader import CalibreClient
from uploader import CalibreClient, CalibreUnavailableError
log = logging.getLogger(__name__)
@@ -86,6 +86,7 @@ def run_sync(limit: int | None = None) -> None:
t2 = time.monotonic()
status = client.upload(book, zip_source=remote_zip.remote_path)
log.info("Upload '%s'%s (%.1fs)", book.name, status, time.monotonic() - t2)
time.sleep(2)
if status == "uploaded":
counters["books_uploaded"] += 1
elif status == "skipped_duplicate":
@@ -99,6 +100,11 @@ def run_sync(limit: int | None = None) -> None:
zip_error = f"{books_errored_this_zip} book upload(s) failed — will retry next sync"
extractor.cleanup(work_dir / "extracted" / local_zip.stem)
except CalibreUnavailableError as e:
log.error("Calibre-Web unavailable — aborting sync run: %s", e)
db.mark_zip_processed(remote_zip.remote_path, remote_zip.file_size, "error", str(e))
db.finish_sync_run(run_id, status="error", error_msg=str(e), **counters)
return
except Exception as e:
log.error("Error processing %s: %s", remote_zip.remote_path, e)
zip_status = "error"