浏览代码

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

stevenyomi 2 年之前
父节点
当前提交
f4c684b4b8

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/coil/MangaCoverFetcher.kt

@@ -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()
     }
 }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateService.kt

@@ -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()
 

+ 1 - 1
core/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt

@@ -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 ->

+ 0 - 1
core/src/main/java/eu/kanade/tachiyomi/network/Requests.kt

@@ -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,

+ 3 - 7
source-api/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt

@@ -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)
+        // images will be cached or saved manually, so don't take up network cache
+        return client.newCachelessCallWithProgress(imageRequest(page), page)
             .asObservableSuccess()
     }