Adjust download cache to ignore irrelevant files

Fixes #8530

(cherry picked from commit 9da232dcd8)

# Conflicts:
#	i18n/src/main/res/values/strings.xml
This commit is contained in:
arkon
2022-11-13 11:52:11 -05:00
committed by Jobobby04
parent 33f57f6df7
commit 584bf7dc13
2 changed files with 12 additions and 6 deletions
@@ -299,10 +299,17 @@ class DownloadCache(
mangaDirs.values.forEach { mangaDir ->
val chapterDirs = mangaDir.dir.listFiles().orEmpty()
.mapNotNull { chapterDir ->
chapterDir.name
?.replace(".cbz", "")
?.takeUnless { it.endsWith(Downloader.TMP_DIR_SUFFIX) }
.mapNotNull {
when {
// Ignore incomplete downloads
it.name?.endsWith(Downloader.TMP_DIR_SUFFIX) == true -> null
// Folder of images
it.isDirectory -> it.name
// CBZ files
it.isFile && it.name?.endsWith(".cbz") == true -> it.name!!.replace(".cbz", "")
// Anything else is irrelevant
else -> null
}
}
.toMutableSet()