fix(local/7z): Fix loading previous pages (#2)

This commit is contained in:
Claudemirovsky 2024-01-03 20:26:31 -03:00 committed by GitHub
parent 9e8b14d141
commit 329bf1039d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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()

View File

@ -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
}
}

View File

@ -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 -> {