From 0de214c3b56d6a4eb4f702f472fe45353cec6dfc Mon Sep 17 00:00:00 2001 From: len Date: Thu, 5 May 2016 16:05:36 +0200 Subject: [PATCH] Delete from the download queue on the main thread. It could fix some crashes --- .../kanade/tachiyomi/data/download/DownloadManager.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 815cc060c..2967f1fa8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -57,6 +57,12 @@ class DownloadManager(private val context: Context, private val sourceManager: S .lift(DynamicConcurrentMergeOperator({ downloadChapter(it) }, threadsSubject)) .onBackpressureBuffer() .observeOn(AndroidSchedulers.mainThread()) + .doOnNext { + // Delete successful downloads from queue + if (it.status == Download.DOWNLOADED) { + queue.del(it) + } + } .map { download -> areAllDownloadsFinished() } .subscribe({ finished -> if (finished!!) { @@ -302,10 +308,6 @@ class DownloadManager(private val context: Context, private val sourceManager: S } download.totalProgress = actualProgress download.status = status - // Delete successful downloads from queue after notifying - if (status == Download.DOWNLOADED) { - queue.del(download) - } } // Return the page list from the chapter's directory if it exists, null otherwise