Fix tmp cbzs are counted towards manga download count (#7909)

* Fix tmp cbzs are counted towards manga download count

* Review Changes

* Review Changes 2
This commit is contained in:
AntsyLich 2022-09-02 20:03:37 +06:00 committed by GitHub
parent 8ef200861c
commit a43754e1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -107,9 +107,7 @@ class DownloadCache(
if (sourceDir != null) { if (sourceDir != null) {
val mangaDir = sourceDir.files[provider.getMangaDirName(manga.title)] val mangaDir = sourceDir.files[provider.getMangaDirName(manga.title)]
if (mangaDir != null) { if (mangaDir != null) {
return mangaDir.files return mangaDir.files.size
.filter { !it.endsWith(Downloader.TMP_DIR_SUFFIX) }
.size
} }
} }
return 0 return 0
@ -155,7 +153,11 @@ class DownloadCache(
mangaDirs.values.forEach { mangaDir -> mangaDirs.values.forEach { mangaDir ->
val chapterDirs = mangaDir.dir.listFiles() val chapterDirs = mangaDir.dir.listFiles()
.orEmpty() .orEmpty()
.mapNotNull { it.name?.replace(".cbz", "") } .mapNotNull { chapterDir ->
chapterDir.name
?.replace(".cbz", "")
?.takeUnless { it.endsWith(Downloader.TMP_DIR_SUFFIX) }
}
.toHashSet() .toHashSet()
mangaDir.files = chapterDirs mangaDir.files = chapterDirs

View File

@ -541,7 +541,7 @@ class Downloader(
dirname: String, dirname: String,
tmpDir: UniFile, tmpDir: UniFile,
) { ) {
val zip = mangaDir.createFile("$dirname.cbz.tmp") val zip = mangaDir.createFile("$dirname.cbz$TMP_DIR_SUFFIX")
ZipOutputStream(BufferedOutputStream(zip.openOutputStream())).use { zipOut -> ZipOutputStream(BufferedOutputStream(zip.openOutputStream())).use { zipOut ->
zipOut.setMethod(ZipEntry.STORED) zipOut.setMethod(ZipEntry.STORED)