diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt index 7214ecd940..fce806ae87 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt @@ -94,15 +94,13 @@ class CoverCache(val context: Context) { } /** - * Clear out online covers until its under a certain size + * Clear out all online covers */ fun deleteAllCachedCovers() { GlobalScope.launch(Dispatchers.IO) { val directory = onlineCoverDirectory val size = DiskUtil.getDirectorySize(directory) - if (size <= maxOnlineCacheSize) { - return@launch - } + var deletedSize = 0L val files = directory.listFiles()?.sortedBy { it.lastModified() }?.iterator() ?: return@launch 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 80dcdc7172..0c2052284c 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 @@ -118,6 +118,12 @@ class DownloadCache( } } + fun forceRenewCache() { + renew() + lastRenew = System.currentTimeMillis() + } + + /** * Renews the downloads cache. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index b2e9729126..937a7236a8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -372,6 +372,11 @@ class DownloadManager(val context: Context) { } } + // forceRefresh the download cache + fun refreshCache() { + cache.forceRenewCache() + } + fun addListener(listener: DownloadQueue.DownloadListener) = queue.addListener(listener) fun removeListener(listener: DownloadQueue.DownloadListener) = queue.removeListener(listener) -} +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 0109e80aab..7c261807f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -52,6 +52,8 @@ class SettingsAdvancedController : SettingsController() { private val coverCache: CoverCache by injectLazy() + private val downloadManager: DownloadManager by injectLazy() + @SuppressLint("BatteryLife") override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.advanced @@ -103,6 +105,12 @@ class SettingsAdvancedController : SettingsController() { onClick { clearChapterCache() } } + preference { + titleRes = R.string.force_download_cache_refresh + summaryRes = R.string.force_download_cache_refresh_summary + onClick { downloadManager.refreshCache() } + } + preference { key = "clean_cached_covers" titleRes = R.string.clean_up_cached_covers @@ -220,7 +228,6 @@ class SettingsAdvancedController : SettingsController() { job = GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) { val mangaList = db.getMangas().executeAsBlocking() val sourceManager: SourceManager = Injekt.get() - val downloadManager: DownloadManager = Injekt.get() val downloadProvider = DownloadProvider(activity!!) var foldersCleared = 0 val sources = sourceManager.getOnlineSources() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b9756e455c..d4fa93ce8b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -668,6 +668,9 @@ Clear chapter cache + Refresh the download cache + This will force the download cache to recalculate. Useful if you copied downloads outside of this app and want the app to pick them up + Data Management Crash logs Dump crash logs