Remove cache control on already cacheless image request (#8085)

This commit is contained in:
stevenyomi 2022-09-27 05:13:03 +08:00 committed by GitHub
parent 869396b1a4
commit f4c684b4b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 12 deletions

View file

@ -14,7 +14,6 @@ import eu.kanade.domain.manga.model.MangaCover
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.coil.MangaCoverFetcher.Companion.USE_CUSTOM_COVER
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.network.CACHE_CONTROL_NO_STORE
import eu.kanade.tachiyomi.network.await
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.HttpSource
@ -334,6 +333,7 @@ class MangaCoverFetcher(
companion object {
const val USE_CUSTOM_COVER = "use_custom_cover"
private val CACHE_CONTROL_NO_STORE = CacheControl.Builder().noStore().build()
private val CACHE_CONTROL_NO_NETWORK_NO_CACHE = CacheControl.Builder().noCache().onlyIfCached().build()
}
}

View file

@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.ProgressListener
import eu.kanade.tachiyomi.network.await
import eu.kanade.tachiyomi.network.newCallWithProgress
import eu.kanade.tachiyomi.network.newCachelessCallWithProgress
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.storage.saveTo
@ -119,7 +119,7 @@ class AppUpdateService : Service() {
try {
// Download the new update.
val call = network.client.newCallWithProgress(GET(url), progressListener)
val call = network.client.newCachelessCallWithProgress(GET(url), progressListener)
runningCall = call
val response = call.await()

View file

@ -101,7 +101,7 @@ fun Call.asObservableSuccess(): Observable<Response> {
}
}
fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListener): Call {
fun OkHttpClient.newCachelessCallWithProgress(request: Request, listener: ProgressListener): Call {
val progressClient = newBuilder()
.cache(null)
.addNetworkInterceptor { chain ->

View file

@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit.MINUTES
private val DEFAULT_CACHE_CONTROL = CacheControl.Builder().maxAge(10, MINUTES).build()
private val DEFAULT_HEADERS = Headers.Builder().build()
private val DEFAULT_BODY: RequestBody = FormBody.Builder().build()
val CACHE_CONTROL_NO_STORE = CacheControl.Builder().noStore().build()
fun GET(
url: String,

View file

@ -1,10 +1,9 @@
package eu.kanade.tachiyomi.source.online
import eu.kanade.tachiyomi.network.CACHE_CONTROL_NO_STORE
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.network.newCallWithProgress
import eu.kanade.tachiyomi.network.newCachelessCallWithProgress
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
@ -301,11 +300,8 @@ abstract class HttpSource : CatalogueSource {
* @param page the page whose source image has to be downloaded.
*/
fun fetchImage(page: Page): Observable<Response> {
val request = imageRequest(page).newBuilder()
// images will be cached or saved manually, so don't take up network cache
.cacheControl(CACHE_CONTROL_NO_STORE)
.build()
return client.newCallWithProgress(request, page)
return client.newCachelessCallWithProgress(imageRequest(page), page)
.asObservableSuccess()
}