mirror of
https://github.com/gotson/komga.git
synced 2025-12-20 23:45:11 +01:00
fix: rar extractor could mis-analyze some images
This commit is contained in:
parent
f1dcd65ac3
commit
bd15aecccc
1 changed files with 7 additions and 8 deletions
|
|
@ -30,14 +30,13 @@ class RarExtractor(
|
|||
.filter { !it.isDirectory }
|
||||
.map { entry ->
|
||||
try {
|
||||
rar.getInputStream(entry).buffered().use { stream ->
|
||||
val mediaType = contentDetector.detectMediaType(stream)
|
||||
val dimension = if (contentDetector.isImage(mediaType))
|
||||
imageAnalyzer.getDimension(stream)
|
||||
else
|
||||
null
|
||||
MediaContainerEntry(name = entry.fileName, mediaType = mediaType, dimension = dimension)
|
||||
}
|
||||
val buffer = rar.getInputStream(entry).use { it.readBytes() }
|
||||
val mediaType = buffer.inputStream().use { contentDetector.detectMediaType(it) }
|
||||
val dimension = if (contentDetector.isImage(mediaType))
|
||||
buffer.inputStream().use { imageAnalyzer.getDimension(it) }
|
||||
else
|
||||
null
|
||||
MediaContainerEntry(name = entry.fileName, mediaType = mediaType, dimension = dimension)
|
||||
} catch (e: Exception) {
|
||||
logger.warn(e) { "Could not analyze entry: ${entry.fileName}" }
|
||||
MediaContainerEntry(name = entry.fileName, comment = e.message)
|
||||
|
|
|
|||
Loading…
Reference in a new issue