From 730b093a5fdece49ea2248d02d1c05d1de4f58cb Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Tue, 16 Sep 2025 11:38:14 +0800 Subject: [PATCH] refactor: add more logs when epub extension is missing --- .../kotlin/org/gotson/komga/domain/service/BookLifecycle.kt | 2 ++ .../org/gotson/komga/interfaces/api/kobo/KoboController.kt | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt index eaed0455e..980648118 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt @@ -418,6 +418,7 @@ class BookLifecycle( val extension = mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub ?: throw IllegalArgumentException("Epub extension not found") + .also { logger.error { "Epub extension not found for book ${book.id}. Book should be re-analyzed." } } extension.positions[page - 1] } else { null @@ -496,6 +497,7 @@ class BookLifecycle( val extension = mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub ?: throw IllegalArgumentException("Epub extension not found") + .also { logger.error { "Epub extension not found for book ${book.id}. Book should be re-analyzed." } } // match progression with positions val matchingPositions = extension.positions.filter { it.href == href } val matchedPosition = diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt index c382e0769..f92fba46b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt @@ -570,7 +570,10 @@ class KoboController( locator = if (koboUpdate.statusInfo.status == StatusDto.FINISHED) { // If the book is finished, Kobo sends the first resource instead of the last, so we can't trust what Kobo sent - val epubExtension = mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub ?: throw IllegalArgumentException("Epub extension not found") + val epubExtension = + mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub + ?: throw IllegalArgumentException("Epub extension not found") + .also { logger.error { "Epub extension not found for book ${book.id}. Book should be re-analyzed." } } epubExtension.positions.last() } else { R2Locator(