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 shouldFetchRemotely
) )
val tmpFile = File(coverFile.absolutePath + "_tmp") if (options.diskCachePolicy.writeEnabled) {
body.source().use { input -> val tmpFile = File(coverFile.absolutePath + "_tmp")
tmpFile.sink().buffer().use { output -> body.source().use { input ->
output.writeAll(input) tmpFile.sink().buffer().use { output ->
} output.writeAll(input)
} }
if (response.isSuccessful || !coverFile.exists()) {
if (coverFile.exists()) {
coverFile.delete()
} }
tmpFile.renameTo(coverFile) if (response.isSuccessful || !coverFile.exists()) {
} if (coverFile.exists()) {
if (manga.favorite) { coverFile.delete()
coverCache.deleteCachedCovers() }
tmpFile.renameTo(coverFile)
}
if (manga.favorite) {
coverCache.deleteCachedCovers()
}
} }
return fileLoader(coverFile) return fileLoader(coverFile)
} }

View File

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