From 343add104792f0b988b4254c0ce64977535962d6 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 12 Mar 2025 13:48:31 +0800 Subject: [PATCH] fix: epubs would have a "null" comment in the Media --- .../org/gotson/komga/domain/service/BookAnalyzer.kt | 7 ++++++- .../gotson/komga/domain/service/BookAnalyzerTest.kt | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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 2dbf1ebb3..60232fbfc 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 @@ -202,7 +202,12 @@ class BookAnalyzer( .map { it.fileName } .ifEmpty { null } ?.joinToString(prefix = "ERR_1033 [", postfix = "]") { it } - val allErrors = (errors + entriesErrorSummary).joinToString(" ") + + val allErrors = + (errors + entriesErrorSummary) + .filterNotNull() + .joinToString(" ") + .ifBlank { null } return Media( status = Media.Status.READY, diff --git a/komga/src/test/kotlin/org/gotson/komga/domain/service/BookAnalyzerTest.kt b/komga/src/test/kotlin/org/gotson/komga/domain/service/BookAnalyzerTest.kt index 09a278478..8705dfd2e 100644 --- a/komga/src/test/kotlin/org/gotson/komga/domain/service/BookAnalyzerTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/domain/service/BookAnalyzerTest.kt @@ -162,6 +162,18 @@ class BookAnalyzerTest( assertThat(media.pages).hasSize(0) } + @Test + fun `given regular epub archive when analyzing then comment is empty`() { + val file = ClassPathResource("epub/The Incomplete Theft - Ralph Burke.epub") + val book = Book("book", file.url, LocalDateTime.now()) + + val media = bookAnalyzer.analyze(book, false) + + assertThat(media.mediaType).isEqualTo("application/epub+zip") + assertThat(media.status).isEqualTo(Media.Status.READY) + assertThat(media.comment).isNull() + } + @Test fun `given epub archive when toc cannot be extracted then media status is READY with comments`() { val file = ClassPathResource("epub/The Incomplete Theft - Ralph Burke.epub")