feat: 修复下载bug

pull/274/head
gedoor 4 years ago
parent 999aa86f8d
commit d9c55c783d
  1. 28
      app/src/main/java/io/legado/app/service/DownloadService.kt

@ -89,10 +89,15 @@ class DownloadService : BaseService() {
private fun getBook(bookUrl: String): Book? {
var book = bookMap[bookUrl]
if (book == null) {
book = App.db.bookDao().getBook(bookUrl)
}
if (book == null) {
removeDownload(bookUrl)
synchronized(this) {
book = bookMap[bookUrl]
if (book == null) {
book = App.db.bookDao().getBook(bookUrl)
}
if (book == null) {
removeDownload(bookUrl)
}
}
}
return book
}
@ -100,13 +105,18 @@ class DownloadService : BaseService() {
private fun getWebBook(bookUrl: String, origin: String): WebBook? {
var webBook = webBookMap[origin]
if (webBook == null) {
App.db.bookSourceDao().getBookSource(origin)?.let {
webBook = WebBook(it)
synchronized(this) {
webBook = webBookMap[origin]
if (webBook == null) {
App.db.bookSourceDao().getBookSource(origin)?.let {
webBook = WebBook(it)
}
}
if (webBook == null) {
removeDownload(bookUrl)
}
}
}
if (webBook == null) {
removeDownload(bookUrl)
}
return webBook
}

Loading…
Cancel
Save