mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Manga cover updates (#3101)
* cover caching overhaul * add ui for removing custom cover * skip some loading work * minor cleanup * allow refresh library metadata to refresh local manga * rename metadata_date to cover_last_modified * rearrange removeMangaFromLibrary * change custom cover directory add setting for updating cover when refreshing library * remove toggle and explicit action for updating covers
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import java.util.Date
|
||||
|
||||
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) {
|
||||
cover_last_modified = Date().time
|
||||
|
||||
if (!isLocal()) {
|
||||
coverCache.deleteFromCache(this, false)
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user