refactor: add more logs when epub extension is missing

This commit is contained in:
Gauthier Roebroeck 2025-09-16 11:38:14 +08:00
parent 2f9b4e75d2
commit 730b093a5f
2 changed files with 6 additions and 1 deletions

View file

@ -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 =

View file

@ -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(