calibre upload errors

This commit is contained in:
2026-05-10 16:40:42 +02:00
parent 8e208e4701
commit 6e91358245
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -63,6 +63,7 @@ class CalibreClient:
if not self._upload_csrf:
page = self._session.get(f"{self._cfg.url}/upload", timeout=30)
self._upload_csrf = _extract_csrf(page.text)
log.debug("Upload CSRF token: %s", self._upload_csrf[:12] + "" if self._upload_csrf else "NOT FOUND")
mime = MIME_TYPES.get(book_path.suffix.lower(), "application/octet-stream")
with book_path.open("rb") as fh:
@@ -72,10 +73,15 @@ class CalibreClient:
data={"csrf_token": self._upload_csrf} if self._upload_csrf else {},
timeout=120,
)
if not resp.ok:
log.error("Upload HTTP %s — response body: %s", resp.status_code, resp.text[:500])
resp.raise_for_status()
log.info("Uploaded: %s", book_path.name)
db.record_book(book_path.name, file_hash, zip_source, "uploaded")
return "uploaded"
except requests.HTTPError:
db.record_book(book_path.name, file_hash, zip_source, "error")
return "error"
except Exception as e:
log.error("Upload failed for %s: %s", book_path.name, e)
db.record_book(book_path.name, file_hash, zip_source, "error")