mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 02:02:04 +01:00
Clear cover cache when refreshing manga, even if it's the same url
This commit is contained in:
parent
73df525939
commit
77a0244373
@ -228,7 +228,10 @@ class CoverCache(val context: Context) {
|
|||||||
// Remove file
|
// Remove file
|
||||||
val file = getCoverFile(manga)
|
val file = getCoverFile(manga)
|
||||||
if (deleteCustom) deleteCustomCover(manga)
|
if (deleteCustom) deleteCustomCover(manga)
|
||||||
if (file.exists()) file.delete()
|
if (file.exists()) {
|
||||||
|
Coil.imageLoader(context).invalidate(file.name)
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCacheDir(dir: String): File {
|
private fun getCacheDir(dir: String): File {
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Application
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
|
import coil.Coil
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
@ -341,6 +342,8 @@ class MangaDetailsPresenter(
|
|||||||
|
|
||||||
if (thumbnailUrl != networkManga.thumbnail_url) {
|
if (thumbnailUrl != networkManga.thumbnail_url) {
|
||||||
coverCache.deleteFromCache(thumbnailUrl)
|
coverCache.deleteFromCache(thumbnailUrl)
|
||||||
|
} else {
|
||||||
|
coverCache.deleteFromCache(manga, false)
|
||||||
}
|
}
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
controller.setPaletteColor()
|
controller.setPaletteColor()
|
||||||
|
@ -10,49 +10,6 @@ import java.util.Date
|
|||||||
|
|
||||||
fun Manga.isLocal() = source == LocalSource.ID
|
fun Manga.isLocal() = source == LocalSource.ID
|
||||||
|
|
||||||
/*
|
|
||||||
/**
|
|
||||||
* Call before updating [Manga.thumbnail_url] to ensure old cover can be cleared from cache
|
|
||||||
*/
|
|
||||||
fun Manga.prepUpdateCover(coverCache: CoverCache, remoteManga: SManga, refreshSameUrl: Boolean) {
|
|
||||||
// Never refresh covers if the new url is null, as the current url has possibly become invalid
|
|
||||||
val newUrl = remoteManga.thumbnail_url ?: return
|
|
||||||
|
|
||||||
// Never refresh covers if the url is empty to avoid "losing" existing covers
|
|
||||||
if (newUrl.isEmpty()) return
|
|
||||||
|
|
||||||
if (!refreshSameUrl && thumbnail_url == newUrl) return
|
|
||||||
|
|
||||||
when {
|
|
||||||
isLocal() -> {
|
|
||||||
cover_last_modified = Date().time
|
|
||||||
}
|
|
||||||
hasCustomCover(coverCache) -> {
|
|
||||||
coverCache.deleteFromCache(this, false)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
cover_last_modified = Date().time
|
|
||||||
coverCache.deleteFromCache(this, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Manga.hasCustomCover(coverCache: CoverCache): Boolean {
|
|
||||||
return coverCache.getCustomCoverFile(this).exists()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Manga.removeCovers(coverCache: CoverCache) {
|
|
||||||
if (isLocal()) return
|
|
||||||
|
|
||||||
cover_last_modified = Date().time
|
|
||||||
coverCache.deleteFromCache(this, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Manga.updateCoverLastModified(db: DatabaseHelper) {
|
|
||||||
cover_last_modified = Date().time
|
|
||||||
db.updateMangaCoverLastModified(this).executeAsBlocking()
|
|
||||||
}*/
|
|
||||||
|
|
||||||
fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper): Boolean {
|
fun Manga.shouldDownloadNewChapters(db: DatabaseHelper, prefs: PreferencesHelper): Boolean {
|
||||||
if (!favorite) return false
|
if (!favorite) return false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user