Skip to content

Commit

Permalink
fix(komga): ignore missing epub resources
Browse files Browse the repository at this point in the history
Closes: #1386
  • Loading branch information
gotson committed Jan 19, 2024
1 parent 270a50c commit 22c2131
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions ERRORCODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
| ERR_1030 | ComicRack CBL has no Name element |
| ERR_1031 | ComicRack CBL Book is missing series or number |
| ERR_1032 | EPUB file has wrong media type |
| ERR_1033 | Some entries are missing |
3 changes: 2 additions & 1 deletion komga-webui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@
"ERR_1029": "ComicRack CBL does not contain any Book element",
"ERR_1030": "ComicRack CBL has no Name element",
"ERR_1031": "ComicRack CBL Book is missing series or number",
"ERR_1032": "EPUB file has wrong media type"
"ERR_1032": "EPUB file has wrong media type",
"ERR_1033": "Some entries are missing"
},
"filter": {
"age_rating": "age rating",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class BookAnalyzer(

private fun analyzeEpub(book: Book, analyzeDimensions: Boolean): Media {
val manifest = epubExtractor.getManifest(book.path, analyzeDimensions)
val entriesErrorSummary = manifest.missingResources
.map { it.fileName }
.ifEmpty { null }
?.joinToString(prefix = "ERR_1033 [", postfix = "]") { it }
return Media(
status = Media.Status.READY,
pages = manifest.divinaPages,
Expand All @@ -142,6 +146,7 @@ class BookAnalyzer(
isFixedLayout = manifest.isFixedLayout,
positions = manifest.positions,
),
comment = entriesErrorSummary,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ class EpubExtractor(

fun getManifest(path: Path, analyzeDimensions: Boolean): EpubManifest =
path.epub { epub ->
val resources = getResources(epub)
val (resources, missingResources) = getResources(epub).partition { it.fileSize != null }
val isFixedLayout = isFixedLayout(epub)
val pageCount = computePageCount(epub)
EpubManifest(
resources = resources,
missingResources = missingResources,
toc = getToc(epub),
landmarks = getLandmarks(epub),
pageList = getPageList(epub),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gotson.komga.domain.model.R2Locator

data class EpubManifest(
val resources: List<MediaFile>,
val missingResources: List<MediaFile>,
val toc: List<EpubTocEntry>,
val landmarks: List<EpubTocEntry>,
val pageList: List<EpubTocEntry>,
Expand Down

0 comments on commit 22c2131

Please sign in to comment.