mirror of
https://github.com/gotson/komga.git
synced 2026-05-09 05:10:19 +02: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 }
|
.filter { !it.isDirectory }
|
||||||
.map { entry ->
|
.map { entry ->
|
||||||
try {
|
try {
|
||||||
rar.getInputStream(entry).buffered().use { stream ->
|
val buffer = rar.getInputStream(entry).use { it.readBytes() }
|
||||||
val mediaType = contentDetector.detectMediaType(stream)
|
val mediaType = buffer.inputStream().use { contentDetector.detectMediaType(it) }
|
||||||
val dimension = if (contentDetector.isImage(mediaType))
|
val dimension = if (contentDetector.isImage(mediaType))
|
||||||
imageAnalyzer.getDimension(stream)
|
buffer.inputStream().use { imageAnalyzer.getDimension(it) }
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
MediaContainerEntry(name = entry.fileName, mediaType = mediaType, dimension = dimension)
|
MediaContainerEntry(name = entry.fileName, mediaType = mediaType, dimension = dimension)
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.warn(e) { "Could not analyze entry: ${entry.fileName}" }
|
logger.warn(e) { "Could not analyze entry: ${entry.fileName}" }
|
||||||
MediaContainerEntry(name = entry.fileName, comment = e.message)
|
MediaContainerEntry(name = entry.fileName, comment = e.message)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue