From 08e6487a9aa169ec40be29514da817f67bde517e Mon Sep 17 00:00:00 2001 From: Two-Ai <81279822+Two-Ai@users.noreply.github.com> Date: Tue, 21 Feb 2023 18:21:00 -0500 Subject: [PATCH] Fix download queue page count display bug (#9126) When restarting a download, the page count would display as 0 until the first page download completion, after all the existing pages were rechecked. To fix, calculate downloadedImages from pages instead of relying on the downloader to reset and increment the count. (cherry picked from commit 779df32e98f2a020ca6a4f79c0748dd9f5b16873) --- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 2 -- .../java/eu/kanade/tachiyomi/data/download/model/Download.kt | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 9f350b7dd..1e52470f1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -339,7 +339,6 @@ class Downloader( ?.filter { it.name!!.endsWith(".tmp") } ?.forEach { it.delete() } - download.downloadedImages = 0 download.status = Download.State.DOWNLOADING } // Get all the URLs to the source images, fetch pages if necessary @@ -403,7 +402,6 @@ class Downloader( } page.uri = file.uri page.progress = 100 - download.downloadedImages++ page.status = Page.State.READY } .map { page } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt index 38ddacddb..86eef25c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt @@ -21,9 +21,8 @@ data class Download( val totalProgress: Int get() = pages?.sumOf(Page::progress) ?: 0 - @Volatile - @Transient - var downloadedImages: Int = 0 + val downloadedImages: Int + get() = pages?.count { it.status == Page.State.READY } ?: 0 @Volatile @Transient