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 = val extension =
mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub
?: throw IllegalArgumentException("Epub extension not found") ?: 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] extension.positions[page - 1]
} else { } else {
null null
@ -496,6 +497,7 @@ class BookLifecycle(
val extension = val extension =
mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub mediaRepository.findExtensionByIdOrNull(book.id) as? MediaExtensionEpub
?: throw IllegalArgumentException("Epub extension not found") ?: 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 // match progression with positions
val matchingPositions = extension.positions.filter { it.href == href } val matchingPositions = extension.positions.filter { it.href == href }
val matchedPosition = val matchedPosition =

View file

@ -570,7 +570,10 @@ class KoboController(
locator = locator =
if (koboUpdate.statusInfo.status == StatusDto.FINISHED) { 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 // 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() epubExtension.positions.last()
} else { } else {
R2Locator( R2Locator(