Add option to invalidate download cache (#8491)

* Add option to invalidate download cache

* Review changes + lint
This commit is contained in:
AntsyLich 2022-11-11 09:15:35 +06:00 committed by GitHub
parent c76d5dd30c
commit 08d5633d81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.util.collectAsState import eu.kanade.presentation.util.collectAsState
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.ChapterCache 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.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.preference.PreferenceValues import eu.kanade.tachiyomi.data.preference.PreferenceValues
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
@ -187,6 +188,11 @@ class SettingsAdvancedScreen : SearchableSettings {
pref = libraryPreferences.autoClearChapterCache(), pref = libraryPreferences.autoClearChapterCache(),
title = stringResource(R.string.pref_auto_clear_chapter_cache), 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<DownloadCache>().invalidateCache() },
),
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.pref_clear_database), title = stringResource(R.string.pref_clear_database),
subtitle = stringResource(R.string.pref_clear_database_summary), subtitle = stringResource(R.string.pref_clear_database_summary),

View File

@ -233,6 +233,10 @@ class DownloadCache(
return UniFile.fromUri(context, dir.toUri()) return UniFile.fromUri(context, dir.toUri())
} }
fun invalidateCache() {
lastRenew = 0L
}
/** /**
* Renews the downloads cache. * Renews the downloads cache.
*/ */

View File

@ -505,6 +505,8 @@
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string> <string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
<string name="cache_delete_error">Error occurred while clearing</string> <string name="cache_delete_error">Error occurred while clearing</string>
<string name="pref_auto_clear_chapter_cache">Clear chapter cache on app close</string> <string name="pref_auto_clear_chapter_cache">Clear chapter cache on app close</string>
<string name="pref_invalidate_download_cache">Invalidate download cache</string>
<string name="pref_invalidate_download_cache_summary">Forces the app to reindex downloads</string>
<string name="pref_clear_database">Clear database</string> <string name="pref_clear_database">Clear database</string>
<string name="pref_clear_database_summary">Delete history for entries that are not saved in your library</string> <string name="pref_clear_database_summary">Delete history for entries that are not saved in your library</string>
<string name="clear_database_source_item_count">%1$d non-library entries in database</string> <string name="clear_database_source_item_count">%1$d non-library entries in database</string>