fix(komga): ignore missing epub resources

Closes: #1386
This commit is contained in:
Gauthier Roebroeck 2024-01-19 16:59:55 +08:00
parent 270a50c288
commit 22c21312d2
5 changed files with 11 additions and 2 deletions

View file

@ -36,3 +36,4 @@
| ERR_1030 | ComicRack CBL has no Name element | | ERR_1030 | ComicRack CBL has no Name element |
| ERR_1031 | ComicRack CBL Book is missing series or number | | 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 |

View file

@ -764,7 +764,8 @@
"ERR_1029": "ComicRack CBL does not contain any Book element", "ERR_1029": "ComicRack CBL does not contain any Book element",
"ERR_1030": "ComicRack CBL has no Name element", "ERR_1030": "ComicRack CBL has no Name element",
"ERR_1031": "ComicRack CBL Book is missing series or number", "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": { "filter": {
"age_rating": "age rating", "age_rating": "age rating",

View file

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

View file

@ -69,11 +69,12 @@ class EpubExtractor(
fun getManifest(path: Path, analyzeDimensions: Boolean): EpubManifest = fun getManifest(path: Path, analyzeDimensions: Boolean): EpubManifest =
path.epub { epub -> path.epub { epub ->
val resources = getResources(epub) val (resources, missingResources) = getResources(epub).partition { it.fileSize != null }
val isFixedLayout = isFixedLayout(epub) val isFixedLayout = isFixedLayout(epub)
val pageCount = computePageCount(epub) val pageCount = computePageCount(epub)
EpubManifest( EpubManifest(
resources = resources, resources = resources,
missingResources = missingResources,
toc = getToc(epub), toc = getToc(epub),
landmarks = getLandmarks(epub), landmarks = getLandmarks(epub),
pageList = getPageList(epub), pageList = getPageList(epub),

View file

@ -7,6 +7,7 @@ import org.gotson.komga.domain.model.R2Locator
data class EpubManifest( data class EpubManifest(
val resources: List<MediaFile>, val resources: List<MediaFile>,
val missingResources: List<MediaFile>,
val toc: List<EpubTocEntry>, val toc: List<EpubTocEntry>,
val landmarks: List<EpubTocEntry>, val landmarks: List<EpubTocEntry>,
val pageList: List<EpubTocEntry>, val pageList: List<EpubTocEntry>,