Fix manga covers from browse or extension intents sometimes not showing

This commit is contained in:
Jays2Kings 2021-04-30 23:09:35 -04:00
parent ee42eb347f
commit 59c98f03d5
2 changed files with 20 additions and 18 deletions

View File

@ -85,22 +85,24 @@ class MangaFetcher : Fetcher<Manga> {
shouldFetchRemotely
)
val tmpFile = File(coverFile.absolutePath + "_tmp")
body.source().use { input ->
tmpFile.sink().buffer().use { output ->
output.writeAll(input)
}
}
if (response.isSuccessful || !coverFile.exists()) {
if (coverFile.exists()) {
coverFile.delete()
if (options.diskCachePolicy.writeEnabled) {
val tmpFile = File(coverFile.absolutePath + "_tmp")
body.source().use { input ->
tmpFile.sink().buffer().use { output ->
output.writeAll(input)
}
}
tmpFile.renameTo(coverFile)
}
if (manga.favorite) {
coverCache.deleteCachedCovers()
if (response.isSuccessful || !coverFile.exists()) {
if (coverFile.exists()) {
coverFile.delete()
}
tmpFile.renameTo(coverFile)
}
if (manga.favorite) {
coverCache.deleteCachedCovers()
}
}
return fileLoader(coverFile)
}

View File

@ -12,11 +12,9 @@ import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import coil.loadAny
import coil.request.CachePolicy
import coil.request.Parameters
import com.google.android.material.button.MaterialButton
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.image.coil.MangaFetcher
import eu.kanade.tachiyomi.databinding.MangaHeaderItemBinding
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.model.SManga
@ -329,7 +327,8 @@ class MangaHeaderHolder(
builder = {
placeholder(drawable)
error(drawable)
if (manga.favorite) networkCachePolicy(CachePolicy.DISABLED)
if (manga.favorite) networkCachePolicy(CachePolicy.READ_ONLY)
diskCachePolicy(CachePolicy.READ_ONLY)
}
)
binding.backdrop.loadAny(
@ -337,7 +336,8 @@ class MangaHeaderHolder(
builder = {
placeholder(drawable)
error(drawable)
if (manga.favorite) networkCachePolicy(CachePolicy.DISABLED)
if (manga.favorite) networkCachePolicy(CachePolicy.READ_ONLY)
diskCachePolicy(CachePolicy.READ_ONLY)
}
)
}