mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user