diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 845f99fc0..2efe2985d 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/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 }