This commit is contained in:
Horis
2025-11-21 12:41:57 +08:00
parent 4511b48488
commit 4c01eeea8d
2 changed files with 10 additions and 1 deletions
@@ -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