From aed3d081671dde6b4d5d1fbaf338a080b75c06b2 Mon Sep 17 00:00:00 2001 From: Dude so hot Date: Mon, 21 Oct 2024 18:33:28 +0800 Subject: [PATCH] Fetch from h1 server is NonCancellable --- .../com/hippo/ehviewer/coil/LimitConcurrencyNetworkClient.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/coil/LimitConcurrencyNetworkClient.kt b/app/src/main/kotlin/com/hippo/ehviewer/coil/LimitConcurrencyNetworkClient.kt index bf3d08847..50a4d2489 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/coil/LimitConcurrencyNetworkClient.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/coil/LimitConcurrencyNetworkClient.kt @@ -8,8 +8,10 @@ import com.hippo.ehviewer.Settings import com.hippo.ehviewer.client.URL_PREFIX_THUMB_E import com.hippo.ehviewer.client.URL_PREFIX_THUMB_EX import io.ktor.client.HttpClient +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.withPermit +import kotlinx.coroutines.withContext class LimitConcurrencyNetworkClient(val impl: NetworkClient) : NetworkClient { val eSemaphore = Semaphore(Settings.thumbConcurrency) @@ -18,7 +20,7 @@ class LimitConcurrencyNetworkClient(val impl: NetworkClient) : NetworkClient { val url = req.url return when { URL_PREFIX_THUMB_E in url -> eSemaphore.withPermit { impl.executeRequest(req, f) } - URL_PREFIX_THUMB_EX in url -> exSemaphore.withPermit { impl.executeRequest(req, f) } + URL_PREFIX_THUMB_EX in url -> exSemaphore.withPermit { withContext(NonCancellable) { impl.executeRequest(req, f) } } else -> impl.executeRequest(req, f) } }