* update cover logic when thumbnail url becomes null * always clear cover on refresh even if custom cover is set * remove concurrency changes
This commit is contained in:
parent
dd1b5c7ea7
commit
5723c184b1
@ -396,9 +396,7 @@ class LibraryUpdateService(
|
|||||||
// Update manga details metadata in the background
|
// Update manga details metadata in the background
|
||||||
source.fetchMangaDetails(manga)
|
source.fetchMangaDetails(manga)
|
||||||
.map { networkManga ->
|
.map { networkManga ->
|
||||||
if (manga.thumbnail_url != networkManga.thumbnail_url) {
|
manga.prepUpdateCover(coverCache, networkManga, false)
|
||||||
manga.prepUpdateCover(coverCache)
|
|
||||||
}
|
|
||||||
manga.copyFrom(networkManga)
|
manga.copyFrom(networkManga)
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
manga
|
manga
|
||||||
@ -415,11 +413,23 @@ class LibraryUpdateService(
|
|||||||
var count = 0
|
var count = 0
|
||||||
|
|
||||||
return Observable.from(mangaToUpdate)
|
return Observable.from(mangaToUpdate)
|
||||||
.doOnNext { showProgressNotification(it, count++, mangaToUpdate.size) }
|
.doOnNext {
|
||||||
.map { manga ->
|
showProgressNotification(it, count++, mangaToUpdate.size)
|
||||||
manga.prepUpdateCover(coverCache)
|
}
|
||||||
db.insertManga(manga).executeAsBlocking()
|
.flatMap { manga ->
|
||||||
manga
|
val source = sourceManager.get(manga.source)
|
||||||
|
?: return@flatMap Observable.empty<LibraryManga>()
|
||||||
|
|
||||||
|
source.fetchMangaDetails(manga)
|
||||||
|
.map { networkManga ->
|
||||||
|
manga.prepUpdateCover(coverCache, networkManga, true)
|
||||||
|
networkManga.thumbnail_url?.let {
|
||||||
|
manga.thumbnail_url = it
|
||||||
|
db.insertManga(manga).executeAsBlocking()
|
||||||
|
}
|
||||||
|
manga
|
||||||
|
}
|
||||||
|
.onErrorReturn { manga }
|
||||||
}
|
}
|
||||||
.doOnCompleted {
|
.doOnCompleted {
|
||||||
cancelProgressNotification()
|
cancelProgressNotification()
|
||||||
|
@ -34,6 +34,7 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
|||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight
|
import eu.kanade.tachiyomi.ui.main.offsetAppbarHeight
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
|
import eu.kanade.tachiyomi.util.hasCustomCover
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
@ -487,7 +488,7 @@ class LibraryController(
|
|||||||
private fun handleChangeCover() {
|
private fun handleChangeCover() {
|
||||||
val manga = selectedMangas.firstOrNull() ?: return
|
val manga = selectedMangas.firstOrNull() ?: return
|
||||||
|
|
||||||
if (coverCache.getCustomCoverFile(manga).exists()) {
|
if (manga.hasCustomCover(coverCache)) {
|
||||||
showEditCoverDialog(manga)
|
showEditCoverDialog(manga)
|
||||||
} else {
|
} else {
|
||||||
openMangaCoverPicker(manga)
|
openMangaCoverPicker(manga)
|
||||||
|
@ -75,9 +75,7 @@ class MangaInfoPresenter(
|
|||||||
if (!fetchMangaSubscription.isNullOrUnsubscribed()) return
|
if (!fetchMangaSubscription.isNullOrUnsubscribed()) return
|
||||||
fetchMangaSubscription = Observable.defer { source.fetchMangaDetails(manga) }
|
fetchMangaSubscription = Observable.defer { source.fetchMangaDetails(manga) }
|
||||||
.map { networkManga ->
|
.map { networkManga ->
|
||||||
if (manualFetch || manga.thumbnail_url != networkManga.thumbnail_url) {
|
manga.prepUpdateCover(coverCache, networkManga, manualFetch)
|
||||||
manga.prepUpdateCover(coverCache)
|
|
||||||
}
|
|
||||||
manga.copyFrom(networkManga)
|
manga.copyFrom(networkManga)
|
||||||
manga.initialized = true
|
manga.initialized = true
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
|
@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
|
|||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
fun Manga.isLocal() = source == LocalSource.ID
|
fun Manga.isLocal() = source == LocalSource.ID
|
||||||
@ -11,14 +12,30 @@ fun Manga.isLocal() = source == LocalSource.ID
|
|||||||
/**
|
/**
|
||||||
* Call before updating [Manga.thumbnail_url] to ensure old cover can be cleared from cache
|
* Call before updating [Manga.thumbnail_url] to ensure old cover can be cleared from cache
|
||||||
*/
|
*/
|
||||||
fun Manga.prepUpdateCover(coverCache: CoverCache) {
|
fun Manga.prepUpdateCover(coverCache: CoverCache, remoteManga: SManga, refreshSameUrl: Boolean) {
|
||||||
cover_last_modified = Date().time
|
// Never refresh covers if the new url is null, as the current url has possibly become invalid
|
||||||
|
val newUrl = remoteManga.thumbnail_url ?: return
|
||||||
|
|
||||||
if (!isLocal()) {
|
if (!refreshSameUrl && thumbnail_url == newUrl) return
|
||||||
coverCache.deleteFromCache(this, false)
|
|
||||||
|
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) {
|
fun Manga.removeCovers(coverCache: CoverCache) {
|
||||||
if (isLocal()) return
|
if (isLocal()) return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user