mirror of
https://github.com/mihonapp/mihon.git
synced 2025-02-15 03:28: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()
|
return zip.getImages()
|
||||||
.mapIndexed { i, entry ->
|
.mapIndexed { i, entry ->
|
||||||
ReaderPage(i).apply {
|
ReaderPage(i).apply {
|
||||||
stream = { entry }
|
stream = { entry.copyOf().inputStream() }
|
||||||
status = Page.State.READY
|
status = Page.State.READY
|
||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
|
@ -6,11 +6,11 @@ import tachiyomi.core.util.system.ImageUtil
|
|||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
object SevenZUtil {
|
object SevenZUtil {
|
||||||
fun SevenZFile.getImages(): Sequence<InputStream> {
|
fun SevenZFile.getImages(): Sequence<ByteArray> {
|
||||||
return generateSequence { runCatching { getNextEntry() }.getOrNull() }
|
return generateSequence { runCatching { getNextEntry() }.getOrNull() }
|
||||||
.filter { !it.isDirectory && ImageUtil.isImage(it.name) { getInputStream(it) } }
|
.filter { !it.isDirectory && ImageUtil.isImage(it.name) { getInputStream(it) } }
|
||||||
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
||||||
.map(::getInputStream)
|
.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 ->
|
SevenZFile(format.file.toTempFile(context)).use { archive ->
|
||||||
val entry = archive.getImages().firstOrNull()
|
val entry = archive.getImages().firstOrNull()
|
||||||
|
|
||||||
entry?.let { coverManager.update(manga, it) }
|
entry?.let { coverManager.update(manga, it.inputStream()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Format.Rar -> {
|
is Format.Rar -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user