diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt index a3ebcd9bb..21eeb5e5f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.reader.loader import android.content.Context +import android.os.ParcelFileDescriptor.AutoCloseInputStream import com.github.junrar.exception.UnsupportedRarV5Exception import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadProvider @@ -105,7 +106,8 @@ class ChapterLoader( is Format.Directory -> DirectoryPageLoader(format.file) is Format.Zip -> ZipPageLoader(tempFileManager.createTempFile(format.file)) is Format.SevenZip -> try { - SevenZipPageLoader(format.file) { + val file = context.contentResolver.openFileDescriptor(format.file.uri, "r") + SevenZipPageLoader(AutoCloseInputStream(file)) { GlobalScope.launchUI { context.toast(context.stringResource(MR.strings.loader_7zip_slow_archives, it)) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/SevenZipPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/SevenZipPageLoader.kt index f3d83d6a9..dcbf29f86 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/SevenZipPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/SevenZipPageLoader.kt @@ -1,21 +1,20 @@ package eu.kanade.tachiyomi.ui.reader.loader -import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.util.storage.SevenZUtil.getImages 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. */ internal class SevenZipPageLoader( - private val file: UniFile, + private val file: FileInputStream, private val notifySlowArchive: (method: String) -> Unit, ) : PageLoader() { - private val zip by lazy { SevenZFile(SeekableInMemoryByteChannel(file.openInputStream().readBytes())) } + private val zip by lazy { SevenZFile(file.channel) } override var isLocal: Boolean = true