refactor:remove ConcurrentException

pull/1838/head
Xwite 3 years ago
parent b678363b1e
commit ae5096758c
  1. 8
      app/src/main/java/io/legado/app/exception/ConcurrentException.kt
  2. 5
      app/src/main/java/io/legado/app/model/CacheBook.kt
  3. 5
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt

@ -1,8 +0,0 @@
@file:Suppress("unused")
package io.legado.app.exception
/**
* 并发限制
*/
class ConcurrentException(msg: String, val waitTime: Int) : NoStackTraceException(msg)

@ -8,7 +8,6 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.exception.ConcurrentException
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.service.CacheBookService import io.legado.app.service.CacheBookService
@ -169,9 +168,7 @@ object CacheBook {
@Synchronized @Synchronized
private fun onError(index: Int, error: Throwable, chapterTitle: String) { private fun onError(index: Int, error: Throwable, chapterTitle: String) {
if (error !is ConcurrentException) { errorDownloadMap[index] = (errorDownloadMap[index] ?: 0) + 1
errorDownloadMap[index] = (errorDownloadMap[index] ?: 0) + 1
}
onDownloadSet.remove(index) onDownloadSet.remove(index)
//重试3次 //重试3次
if (errorDownloadMap[index] ?: 0 < 3) { if (errorDownloadMap[index] ?: 0 < 3) {

@ -11,7 +11,6 @@ import io.legado.app.R
import io.legado.app.constant.AppLog import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.exception.ConcurrentException
import io.legado.app.exception.NoStackTraceException import io.legado.app.exception.NoStackTraceException
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
@ -154,10 +153,6 @@ class HttpReadAloudService : BaseReadAloudService(),
}.onFailure { }.onFailure {
when (it) { when (it) {
is CancellationException -> Unit is CancellationException -> Unit
is ConcurrentException -> {
delay(it.waitTime.toLong())
downloadAudio()
}
is ScriptException, is WrappedException -> { is ScriptException, is WrappedException -> {
AppLog.put("js错误\n${it.localizedMessage}", it) AppLog.put("js错误\n${it.localizedMessage}", it)
toastOnUi("js错误\n${it.localizedMessage}") toastOnUi("js错误\n${it.localizedMessage}")

Loading…
Cancel
Save