mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 10:51:52 +01:00
Add refresh download cache, and remove size check for force delete non library cover cache (#872)
* add option to force refresh download cache. Removed size check on clear non library covers because what it does did not match what it said it did * forgot }
This commit is contained in:
parent
d0b4b33466
commit
7585c24566
@ -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
|
||||
|
@ -118,6 +118,12 @@ class DownloadCache(
|
||||
}
|
||||
}
|
||||
|
||||
fun forceRenewCache() {
|
||||
renew()
|
||||
lastRenew = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renews the downloads cache.
|
||||
*/
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -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()
|
||||
|
@ -668,6 +668,9 @@
|
||||
|
||||
<!-- Advanced section -->
|
||||
<string name="clear_chapter_cache">Clear chapter cache</string>
|
||||
<string name="force_download_cache_refresh">Refresh the download cache</string>
|
||||
<string name="force_download_cache_refresh_summary">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</string>
|
||||
|
||||
<string name="data_management">Data Management</string>
|
||||
<string name="crash_logs">Crash logs</string>
|
||||
<string name="dump_crash_logs">Dump crash logs</string>
|
||||
|
Loading…
Reference in New Issue
Block a user