From 657b8dd5b4f48ddc3546c6b7161568fd519b2e77 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 1 Aug 2022 22:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/coroutine/Coroutine.kt | 6 ++++-- .../java/io/legado/app/service/CheckSourceService.kt | 9 --------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt index ff3daea60..5918175f2 100644 --- a/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt +++ b/app/src/main/java/io/legado/app/help/coroutine/Coroutine.kt @@ -115,7 +115,9 @@ class Coroutine( //取消当前任务 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( 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) { diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 1cbdac7df..62637d428 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -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)