mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 06:52:49 +01:00
don't read the entire archive into memory
This commit is contained in:
parent
ffcba7b2dc
commit
415124d20e
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.reader.loader
|
package eu.kanade.tachiyomi.ui.reader.loader
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.ParcelFileDescriptor.AutoCloseInputStream
|
||||||
import com.github.junrar.exception.UnsupportedRarV5Exception
|
import com.github.junrar.exception.UnsupportedRarV5Exception
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||||
@ -105,7 +106,8 @@ class ChapterLoader(
|
|||||||
is Format.Directory -> DirectoryPageLoader(format.file)
|
is Format.Directory -> DirectoryPageLoader(format.file)
|
||||||
is Format.Zip -> ZipPageLoader(tempFileManager.createTempFile(format.file))
|
is Format.Zip -> ZipPageLoader(tempFileManager.createTempFile(format.file))
|
||||||
is Format.SevenZip -> try {
|
is Format.SevenZip -> try {
|
||||||
SevenZipPageLoader(format.file) {
|
val file = context.contentResolver.openFileDescriptor(format.file.uri, "r")
|
||||||
|
SevenZipPageLoader(AutoCloseInputStream(file)) {
|
||||||
GlobalScope.launchUI {
|
GlobalScope.launchUI {
|
||||||
context.toast(context.stringResource(MR.strings.loader_7zip_slow_archives, it))
|
context.toast(context.stringResource(MR.strings.loader_7zip_slow_archives, it))
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package eu.kanade.tachiyomi.ui.reader.loader
|
package eu.kanade.tachiyomi.ui.reader.loader
|
||||||
|
|
||||||
import com.hippo.unifile.UniFile
|
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.util.storage.SevenZUtil.getImages
|
import eu.kanade.tachiyomi.util.storage.SevenZUtil.getImages
|
||||||
import org.apache.commons.compress.archivers.sevenz.SevenZFile
|
import org.apache.commons.compress.archivers.sevenz.SevenZFile
|
||||||
import org.apache.commons.compress.utils.SeekableInMemoryByteChannel
|
import java.io.FileInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader used to load a chapter from a .7z or .cb7 file.
|
* Loader used to load a chapter from a .7z or .cb7 file.
|
||||||
*/
|
*/
|
||||||
internal class SevenZipPageLoader(
|
internal class SevenZipPageLoader(
|
||||||
private val file: UniFile,
|
private val file: FileInputStream,
|
||||||
private val notifySlowArchive: (method: String) -> Unit,
|
private val notifySlowArchive: (method: String) -> Unit,
|
||||||
) : PageLoader() {
|
) : PageLoader() {
|
||||||
|
|
||||||
private val zip by lazy { SevenZFile(SeekableInMemoryByteChannel(file.openInputStream().readBytes())) }
|
private val zip by lazy { SevenZFile(file.channel) }
|
||||||
|
|
||||||
override var isLocal: Boolean = true
|
override var isLocal: Boolean = true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user