Skip to content

Commit

Permalink
Should fix password protect downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jobobby04 committed Feb 17, 2024
1 parent 75c057e commit 8404fb5
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit 8404fb5

Please sign in to comment.