fix: stop retrying ebooks that can't be parsed #55

Merged
jfro merged 1 commit from jtk/ebook-cancel-unprocessable into main 2026-10-18 22:39:42 +00:00
Owner

ProcessWorker returned {:error, reason} for corrupt or unsupported files, so Oban retried each one 3 times and re-hashed the whole file every time, for an error that can't change.

Change

  • extract_metadata/1 now tags parse and unsupported-format errors as {:unprocessable, reason}. On that, do_perform/2 marks the ebook failed (same message as before), updates library progress, logs a warning with the ebook id and file name, and returns {:cancel, reason}.
  • Still retried: file not found (from the stat, or from the extractor if the file vanished in between; a remounted share can bring it back), DB errors (Postgrex raises are re-raised as before), and anything else that comes back as a plain {:error, _}.
  • A non-binary reason from the extractor is inspected now. Before, interpolating it would have crashed.
  • JobFailureHandler already handles :cancelled ProcessWorker jobs. It skips ebooks that are already failed, so the error message isn't overwritten.

Tests

  • Corrupt EPUB → {:cancel, reason}, ebook failed with that reason, cancel logged.
  • Unsupported format (.txt) → {:cancel, _} with "Unsupported file format".
  • A cancelled job still finishes the library's processing stage.
  • Missing file still returns {:error, _} (existing test).

mix precommit passes.

Fixes #22

`ProcessWorker` returned `{:error, reason}` for corrupt or unsupported files, so Oban retried each one 3 times and re-hashed the whole file every time, for an error that can't change. **Change** - `extract_metadata/1` now tags parse and unsupported-format errors as `{:unprocessable, reason}`. On that, `do_perform/2` marks the ebook failed (same message as before), updates library progress, logs a warning with the ebook id and file name, and returns `{:cancel, reason}`. - Still retried: `file not found` (from the stat, or from the extractor if the file vanished in between; a remounted share can bring it back), DB errors (Postgrex raises are re-raised as before), and anything else that comes back as a plain `{:error, _}`. - A non-binary reason from the extractor is `inspect`ed now. Before, interpolating it would have crashed. - `JobFailureHandler` already handles `:cancelled` ProcessWorker jobs. It skips ebooks that are already failed, so the error message isn't overwritten. **Tests** - Corrupt EPUB → `{:cancel, reason}`, ebook failed with that reason, cancel logged. - Unsupported format (`.txt`) → `{:cancel, _}` with "Unsupported file format". - A cancelled job still finishes the library's processing stage. - Missing file still returns `{:error, _}` (existing test). `mix precommit` passes. Fixes #22
jfro added this to the 0.6.2 milestone 2026-10-18 21:46:02 +00:00
fix: stop retrying ebooks that can't be parsed
All checks were successful
CI / test (pull_request) Successful in 1m47s
d40232c010
ProcessWorker returned {:error, reason} for corrupt and unsupported
files, so Oban retried each one 3 times and re-hashed the file every
time. Metadata extraction errors now mark the ebook failed and return
{:cancel, reason}. A missing file and database errors still return or
raise so Oban retries them.

Fixes #22
Author
Owner

Review from Nye (approved)

Checked: "file not found: " prefix matches MetadataExtractor exactly (ZipReader's "File not found in EPUB: " is a missing entry, correctly unprocessable); JobFailureHandler skips already-failed ebooks on :cancelled; failed ebooks are re-queued by ScanWorker on the next scan (scan_worker.ex:282), so a wrong cancel recovers on rescan.

Low (non-blocking, your call):

  1. Transient I/O now cancels: ZipReader rescues File.Error into "Failed to read EPUB file: " (EIO/ESTALE/EACCES on a NAS/NFS hiccup), and a missing pdfinfo binary (System.cmd :enoent, rescued to "Failed to parse PDF: ...") also cancels; recovery only via the next scan. Consider keeping "Failed to read ... file:" as a plain {:error, _} so Oban retries it.
Review from Nye (approved) Checked: "file not found: " prefix matches MetadataExtractor exactly (ZipReader's "File not found in EPUB: <entry>" is a missing entry, correctly unprocessable); JobFailureHandler skips already-failed ebooks on :cancelled; failed ebooks are re-queued by ScanWorker on the next scan (scan_worker.ex:282), so a wrong cancel recovers on rescan. Low (non-blocking, your call): 1. Transient I/O now cancels: ZipReader rescues File.Error into "Failed to read EPUB file: <posix>" (EIO/ESTALE/EACCES on a NAS/NFS hiccup), and a missing pdfinfo binary (System.cmd :enoent, rescued to "Failed to parse PDF: ...") also cancels; recovery only via the next scan. Consider keeping "Failed to read ... file:" as a plain {:error, _} so Oban retries it.
jfro merged commit 2263962d46 into main 2026-10-18 22:39:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/fuzzy_catalog!55
No description provided.