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)
(cherry picked from commit acef44f55cd276ede9e5435ab9ed96062c526a79)
This commit is contained in:
Two-Ai 2023-02-21 18:21:00 -05:00 committed by Jobobby04
parent feec105ebd
commit ea0483e4aa
2 changed files with 2 additions and 5 deletions

View File

@ -351,7 +351,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
@ -415,7 +414,6 @@ class Downloader(
}
page.uri = file.uri
page.progress = 100
download.downloadedImages++
page.status = Page.State.READY
}
.map { page }

View File

@ -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