优化
This commit is contained in:
@@ -191,7 +191,7 @@ object CacheBook {
|
||||
private val tasks = CompositeCoroutine()
|
||||
private var isStopped = false
|
||||
private var waitingRetry = false
|
||||
private var isLoading = true
|
||||
private var isLoading = false
|
||||
|
||||
val waitCount get() = waitDownloadSet.size
|
||||
val onDownloadCount get() = onDownloadSet.size
|
||||
@@ -215,11 +215,17 @@ object CacheBook {
|
||||
return isLoading
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setLoading() {
|
||||
isLoading = true
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun stop() {
|
||||
waitDownloadSet.clear()
|
||||
tasks.clear()
|
||||
isStopped = true
|
||||
isLoading = false
|
||||
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,14 @@ class CacheBookService : BaseService() {
|
||||
val chapterCount = appDb.bookChapterDao.getChapterCount(bookUrl)
|
||||
val book = cacheBook.book
|
||||
if (chapterCount == 0) {
|
||||
cacheBook.setLoading()
|
||||
mutex.withLock {
|
||||
val name = book.name
|
||||
if (book.tocUrl.isEmpty()) {
|
||||
kotlin.runCatching {
|
||||
WebBook.getBookInfoAwait(cacheBook.bookSource, book)
|
||||
}.onFailure {
|
||||
removeDownload(bookUrl)
|
||||
val msg = "《$name》目录为空且加载详情页失败\n${it.localizedMessage}"
|
||||
AppLog.put(msg, it, true)
|
||||
return@execute
|
||||
@@ -122,6 +124,7 @@ class CacheBookService : BaseService() {
|
||||
book.totalChapterNum = 0
|
||||
book.update()
|
||||
}
|
||||
removeDownload(bookUrl)
|
||||
val msg = "《$name》目录为空且加载目录失败\n${it.localizedMessage}"
|
||||
AppLog.put(msg, it, true)
|
||||
return@execute
|
||||
|
||||
Reference in New Issue
Block a user