mirror of
https://github.com/mihonapp/mihon.git
synced 2025-02-14 19:18:56 +01:00
fix(local/7z): Fix loading previous pages (#2)
This commit is contained in:
parent
9e8b14d141
commit
329bf1039d
@ -19,7 +19,7 @@ internal class SevenZipPageLoader(file: File) : PageLoader() {
|
||||
return zip.getImages()
|
||||
.mapIndexed { i, entry ->
|
||||
ReaderPage(i).apply {
|
||||
stream = { entry }
|
||||
stream = { entry.copyOf().inputStream() }
|
||||
status = Page.State.READY
|
||||
}
|
||||
}.toList()
|
||||
|
@ -6,11 +6,11 @@ import tachiyomi.core.util.system.ImageUtil
|
||||
import java.io.InputStream
|
||||
|
||||
object SevenZUtil {
|
||||
fun SevenZFile.getImages(): Sequence<InputStream> {
|
||||
fun SevenZFile.getImages(): Sequence<ByteArray> {
|
||||
return generateSequence { runCatching { getNextEntry() }.getOrNull() }
|
||||
.filter { !it.isDirectory && ImageUtil.isImage(it.name) { getInputStream(it) } }
|
||||
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
||||
.map(::getInputStream)
|
||||
.map { it.use(InputStream::readBytes).inputStream() } // ByteArrayInputStream
|
||||
.map { it.use(InputStream::readBytes) } // ByteArray
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ actual class LocalSource(
|
||||
SevenZFile(format.file.toTempFile(context)).use { archive ->
|
||||
val entry = archive.getImages().firstOrNull()
|
||||
|
||||
entry?.let { coverManager.update(manga, it) }
|
||||
entry?.let { coverManager.update(manga, it.inputStream()) }
|
||||
}
|
||||
}
|
||||
is Format.Rar -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user