From 9da232dcd88421a86312b2c5237107f73b20a4a1 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 13 Nov 2022 11:52:11 -0500 Subject: [PATCH] Adjust download cache to ignore irrelevant files Fixes #8530 --- .../tachiyomi/data/download/DownloadCache.kt | 15 +++++++++++---- i18n/src/main/res/values/strings.xml | 2 +- 2 files changed, 12 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 1aedf7df7..b70dfd2a6 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 @@ -284,10 +284,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() diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index a625ccfb2..f44817b71 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -504,7 +504,7 @@ Cache cleared. %1$d files have been deleted Error occurred while clearing Clear chapter cache on app close - Reindex downloads + Invalidate downloads index Clear database Delete history for entries that are not saved in your library %1$d non-library entries in database