From 22c21312d2a96ef6f9f07a5d7b250c538a2e8cbf Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 19 Jan 2024 16:59:55 +0800 Subject: [PATCH] fix(komga): ignore missing epub resources Closes: #1386 --- ERRORCODES.md | 1 + komga-webui/src/locales/en.json | 3 ++- .../kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt | 5 +++++ .../infrastructure/mediacontainer/epub/EpubExtractor.kt | 3 ++- .../komga/infrastructure/mediacontainer/epub/EpubManifest.kt | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ERRORCODES.md b/ERRORCODES.md index 5d0e140717..2c0c77991a 100644 --- a/ERRORCODES.md +++ b/ERRORCODES.md @@ -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 | diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index f77283c7c4..b02603a0c5 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -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", diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt index e3c9022b9f..46fca1e1d3 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookAnalyzer.kt @@ -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, @@ -142,6 +146,7 @@ class BookAnalyzer( isFixedLayout = manifest.isFixedLayout, positions = manifest.positions, ), + comment = entriesErrorSummary, ) } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubExtractor.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubExtractor.kt index 0eeed14e03..2610a29038 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubExtractor.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubExtractor.kt @@ -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), diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubManifest.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubManifest.kt index 32a999ecdc..ab64f01c04 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubManifest.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/mediacontainer/epub/EpubManifest.kt @@ -7,6 +7,7 @@ import org.gotson.komga.domain.model.R2Locator data class EpubManifest( val resources: List, + val missingResources: List, val toc: List, val landmarks: List, val pageList: List,