Fix skipping download errors
This commit is contained in:
@@ -311,6 +311,10 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
DOWNLOAD_ERROR_DELAY
|
DOWNLOAD_ERROR_DELAY
|
||||||
}
|
}
|
||||||
if (countDown <= 0 || retryDelay < 0 || retryDelay > MAX_RETRY_DELAY) {
|
if (countDown <= 0 || retryDelay < 0 || retryDelay > MAX_RETRY_DELAY) {
|
||||||
|
val pausingHandle = PausingHandle.current()
|
||||||
|
if (pausingHandle.skipAllErrors()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
publishState(
|
publishState(
|
||||||
currentState.copy(
|
currentState.copy(
|
||||||
isPaused = true,
|
isPaused = true,
|
||||||
@@ -321,7 +325,6 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
countDown = MAX_FAILSAFE_ATTEMPTS
|
countDown = MAX_FAILSAFE_ATTEMPTS
|
||||||
val pausingHandle = PausingHandle.current()
|
|
||||||
pausingHandle.pause()
|
pausingHandle.pause()
|
||||||
try {
|
try {
|
||||||
pausingHandle.awaitResumed()
|
pausingHandle.awaitResumed()
|
||||||
|
|||||||
@@ -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> {
|
companion object : CoroutineContext.Key<PausingHandle> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user