Skip corrupt pages instead of aborting the whole conversion - #1399
Open
NilsLeo wants to merge 1 commit into
Open
Skip corrupt pages instead of aborting the whole conversion#1399NilsLeo wants to merge 1 commit into
NilsLeo wants to merge 1 commit into
Conversation
A single unreadable or zero-byte page raised RuntimeError and failed the entire book, even when every other page was fine. Skip the bad page and carry on; keep only the genuine environment error (missing Pillow decoder) as fatal. Also guard against a missing cover so a damaged archive with no usable cover page no longer crashes with a NoneType error.
Contributor
Author
|
@axu2 this is constructed, but ive encountered files like this several times that have these sort of corrupted pages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A single unreadable or zero-byte page raised
RuntimeErrorand failed the entire book, even when every other page was fine. This skips the bad page and carries on, while keeping a genuine environment error (a missing Pillow decoder) fatal so real setup problems still surface. It also guards against a missing cover, so a damaged archive with no usable cover page no longer crashes with aNoneTypeerror.How to reproduce / test
A comic with one zero-byte page and one unreadable/garbage page mixed in with valid pages triggers both fatal branches this PR fixes:
Download: https://drive.google.com/file/d/1rz38SkzJLcZ3D_laJCdC8XYo5nRg9Ghi/view?usp=drive_link
Save it next to where you run the commands (referred to below as
1399.cbz). The archive is flat (images at the root) withpage-003-EMPTY.jpg(0 bytes) andpage-005-GARBAGE.jpg(non-image bytes) between valid pages.The easiest way to A/B test any KCC branch without a local setup is
kcc-run, which clones a givenowner/repo:refinto a throwaway container at runtime:1. Reproduce the crash on upstream master (one corrupt page fails the whole book):
→ aborts with
RuntimeError: Image file .../page-005-GARBAGE.jpg is corrupted.atdetectSuboptimalProcessing; no EPUB produced.2. Same file on this branch — skips the bad pages and converts the rest:
→ logs
then writes a valid
out/1399.epubfrom the remaining pages.(Or clone this branch and run
python kcc-c2e.py -p KV -f EPUB -o out 1399.cbzdirectly.)