From 08d5633d81633ab09f09f1ecedd331f12fa8a889 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Fri, 11 Nov 2022 09:15:35 +0600 Subject: [PATCH] Add option to invalidate download cache (#8491) * Add option to invalidate download cache * Review changes + lint --- .../more/settings/screen/SettingsAdvancedScreen.kt | 6 ++++++ .../java/eu/kanade/tachiyomi/data/download/DownloadCache.kt | 4 ++++ i18n/src/main/res/values/strings.xml | 2 ++ 3 files changed, 12 insertions(+) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index ee8725c1b..5e77ea145 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -31,6 +31,7 @@ import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.util.collectAsState import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache +import eu.kanade.tachiyomi.data.download.DownloadCache import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.track.TrackManager @@ -187,6 +188,11 @@ class SettingsAdvancedScreen : SearchableSettings { pref = libraryPreferences.autoClearChapterCache(), title = stringResource(R.string.pref_auto_clear_chapter_cache), ), + Preference.PreferenceItem.TextPreference( + title = stringResource(R.string.pref_invalidate_download_cache), + subtitle = stringResource(R.string.pref_invalidate_download_cache_summary), + onClick = { Injekt.get().invalidateCache() }, + ), Preference.PreferenceItem.TextPreference( title = stringResource(R.string.pref_clear_database), subtitle = stringResource(R.string.pref_clear_database_summary), 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 67e78d03f..5fa3994ec 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 @@ -233,6 +233,10 @@ class DownloadCache( return UniFile.fromUri(context, dir.toUri()) } + fun invalidateCache() { + lastRenew = 0L + } + /** * Renews the downloads cache. */ diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 4944620a7..7d37e8442 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -505,6 +505,8 @@ Cache cleared. %1$d files have been deleted Error occurred while clearing Clear chapter cache on app close + Invalidate download cache + Forces the app to reindex downloads Clear database Delete history for entries that are not saved in your library %1$d non-library entries in database