mirror of
https://github.com/gotson/komga.git
synced 2026-04-14 02:50:50 +02:00
fix thumbnail generation not using the first page in natural order
This commit is contained in:
parent
d81d3f797b
commit
ff54f08867
2 changed files with 6 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package org.gotson.komga.domain.service
|
|||
|
||||
import mu.KotlinLogging
|
||||
import net.coobird.thumbnailator.Thumbnails
|
||||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadata
|
||||
import org.gotson.komga.domain.model.Status
|
||||
|
|
@ -11,6 +12,7 @@ import org.gotson.komga.infrastructure.archive.RarExtractor
|
|||
import org.gotson.komga.infrastructure.archive.ZipExtractor
|
||||
import org.springframework.stereotype.Service
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.util.*
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
|
|
@ -26,6 +28,8 @@ class BookParser(
|
|||
"application/x-rar-compressed" to rarExtractor
|
||||
)
|
||||
|
||||
private val natSortComparator: Comparator<String> = CaseInsensitiveSimpleNaturalComparator.getInstance()
|
||||
|
||||
private val thumbnailSize = 300
|
||||
private val thumbnailFormat = "png"
|
||||
|
||||
|
|
@ -38,6 +42,7 @@ class BookParser(
|
|||
throw UnsupportedMediaTypeException("Unsupported mime type: $mediaType. File: ${book.url}", mediaType)
|
||||
|
||||
val pages = supportedMediaTypes.getValue(mediaType).getPagesList(book.path())
|
||||
.sortedWith(compareBy(natSortComparator) { it.fileName })
|
||||
logger.info { "Book has ${pages.size} pages" }
|
||||
|
||||
logger.info { "Trying to generate cover for book: ${book.url}" }
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class BookParserTest {
|
|||
//when
|
||||
val thumbnailFile = slot<String>()
|
||||
every { mockZip.getPageStream(book.path(), capture(thumbnailFile)) } returns ByteArray(1)
|
||||
val metadata = bookParser.parse(book)
|
||||
bookParser.parse(book)
|
||||
|
||||
// then
|
||||
assertThat(thumbnailFile.captured).isEqualTo("01")
|
||||
|
|
|
|||
Loading…
Reference in a new issue