From a43754e1a67beb24810ee67a10989c882cd28e56 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Fri, 2 Sep 2022 20:03:37 +0600 Subject: [PATCH] Fix tmp cbzs are counted towards manga download count (#7909) * Fix tmp cbzs are counted towards manga download count * Review Changes * Review Changes 2 --- .../eu/kanade/tachiyomi/data/download/DownloadCache.kt | 10 ++++++---- .../eu/kanade/tachiyomi/data/download/Downloader.kt | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index b303c03f3..dd0e3fe1e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -107,9 +107,7 @@ class DownloadCache( if (sourceDir != null) { val mangaDir = sourceDir.files[provider.getMangaDirName(manga.title)] if (mangaDir != null) { - return mangaDir.files - .filter { !it.endsWith(Downloader.TMP_DIR_SUFFIX) } - .size + return mangaDir.files.size } } return 0 @@ -155,7 +153,11 @@ class DownloadCache( mangaDirs.values.forEach { mangaDir -> val chapterDirs = mangaDir.dir.listFiles() .orEmpty() - .mapNotNull { it.name?.replace(".cbz", "") } + .mapNotNull { chapterDir -> + chapterDir.name + ?.replace(".cbz", "") + ?.takeUnless { it.endsWith(Downloader.TMP_DIR_SUFFIX) } + } .toHashSet() mangaDir.files = chapterDirs 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 d4f45a61b..3fc0ffb76 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -541,7 +541,7 @@ class Downloader( dirname: String, tmpDir: UniFile, ) { - val zip = mangaDir.createFile("$dirname.cbz.tmp") + val zip = mangaDir.createFile("$dirname.cbz$TMP_DIR_SUFFIX") ZipOutputStream(BufferedOutputStream(zip.openOutputStream())).use { zipOut -> zipOut.setMethod(ZipEntry.STORED)