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 13b55ac13..bbe44141c 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -184,9 +184,7 @@ class DownloadService : BaseService() { scope = this, context = searchPool ).onError { - it.localizedMessage?.let { - Download.addLog(it) - } + Download.addLog(it.localizedMessage) }.onSuccess(IO) { content -> downloadCount[book.bookUrl]?.increaseSuccess() BookHelp.saveContent(book, bookChapter, content) diff --git a/app/src/main/java/io/legado/app/service/help/Download.kt b/app/src/main/java/io/legado/app/service/help/Download.kt index 844f127b2..d7e99b641 100644 --- a/app/src/main/java/io/legado/app/service/help/Download.kt +++ b/app/src/main/java/io/legado/app/service/help/Download.kt @@ -9,7 +9,8 @@ object Download { val logs = arrayListOf() - fun addLog(log: String) { + fun addLog(log: String?) { + log ?: return synchronized(this) { if (logs.size > 30) { logs.removeAt(0)