pull/2119/head
kunfei 2 years ago
parent 8779e86f9e
commit 657b8dd5b4
  1. 6
      app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt
  2. 9
      app/src/main/java/io/legado/app/service/CheckSourceService.kt

@ -115,7 +115,9 @@ class Coroutine<T>(
//取消当前任务
fun cancel(cause: ActivelyCancelException = ActivelyCancelException()) {
job.cancel(cause)
if (!job.isCancelled) {
job.cancel(cause)
}
cancel?.let {
MainScope().launch {
if (null == it.context) {
@ -146,7 +148,7 @@ class Coroutine<T>(
success?.let { dispatchCallback(this, value, it) }
} catch (e: Throwable) {
e.printOnDebug()
if (e is CancellationException && isActive) {
if (e is CancellationException && !isActive && e !is ActivelyCancelException) {
this@Coroutine.cancel()
}
if (e is CancellationException && e !is TimeoutCancellationException) {

@ -190,15 +190,6 @@ class CheckSourceService : BaseService() {
}.onSuccess(searchCoroutine) {
source.removeGroup("校验超时")
Debug.updateFinalMessage(source.bookSourceUrl, "校验成功")
}.onCancel(IO) {
source.addGroup("校验超时")
source.bookSourceComment =
"Error: 校验超时" + if (source.bookSourceComment.isNullOrBlank())
"" else "\n\n${source.bookSourceComment}"
Debug.updateFinalMessage(source.bookSourceUrl, "校验失败: 校验超时")
source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
appDb.bookSourceDao.update(source)
onNext(source.bookSourceUrl, source.bookSourceName)
}.onFinally(IO) {
source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
appDb.bookSourceDao.update(source)

Loading…
Cancel
Save