Fix skipping download errors

This commit is contained in:
Koitharu
2024-10-11 10:15:29 +03:00
parent e5c765dd2f
commit 05d22167c4
2 changed files with 7 additions and 2 deletions

View File

@@ -311,6 +311,10 @@ class DownloadWorker @AssistedInject constructor(
DOWNLOAD_ERROR_DELAY
}
if (countDown <= 0 || retryDelay < 0 || retryDelay > MAX_RETRY_DELAY) {
val pausingHandle = PausingHandle.current()
if (pausingHandle.skipAllErrors()) {
return null
}
publishState(
currentState.copy(
isPaused = true,
@@ -321,7 +325,6 @@ class DownloadWorker @AssistedInject constructor(
),
)
countDown = MAX_FAILSAFE_ATTEMPTS
val pausingHandle = PausingHandle.current()
pausingHandle.pause()
try {
pausingHandle.awaitResumed()

View File

@@ -53,7 +53,9 @@ class PausingHandle : AbstractCoroutineContextElement(PausingHandle) {
}
}
fun skipCurrentError(): Boolean = skipError.compareAndSet(expect = true, update = skipAllErrors)
fun skipAllErrors(): Boolean = skipAllErrors
fun skipCurrentError(): Boolean = skipError.compareAndSet(expect = true, update = false)
companion object : CoroutineContext.Key<PausingHandle> {