From 8404fb57383857abc19f13f38006eb3d9d72c082 Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Sat, 17 Feb 2024 16:14:10 -0500 Subject: [PATCH] Should fix password protect downloads --- .../eu/kanade/tachiyomi/data/download/Downloader.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index d43d35485a..c5a35c01da 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -663,7 +663,8 @@ class Downloader( dirname: String, tmpDir: UniFile, ) { - val zip = ZipFile("${mangaDir.filePath}/$dirname.cbz$TMP_DIR_SUFFIX") + val zipFile = File(context.externalCacheDir, "$dirname.cbz$TMP_DIR_SUFFIX") + val zip = ZipFile(zipFile) val zipParameters = ZipParameters() CbzCrypto.setZipParametersEncrypted(zipParameters) @@ -676,9 +677,17 @@ class Downloader( tmpDir.listFiles()?.map { img -> img.filePath?.let { File(it) } }, zipParameters, ) + zip.close() + val realZip = mangaDir.createFile("$dirname.cbz$TMP_DIR_SUFFIX")!! + realZip.openOutputStream().use { out -> + zipFile.inputStream().use { + it.copyTo(out) + } + } mangaDir.findFile("$dirname.cbz$TMP_DIR_SUFFIX")?.renameTo("$dirname.cbz") tmpDir.delete() + zipFile.delete() } private fun addPaddingToImage(imageDir: File) {