Merge pull request #7259 from Bnyro/master

fix: automatically resume next paused download item after finishing previous one
This commit is contained in:
Bnyro 2025-03-31 16:48:41 +02:00 committed by GitHub
commit a6ccb5bfaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -227,11 +227,17 @@ class DownloadService : LifecycleService() {
downloadQueue[item.id] = false
if (_downloadFlow.firstOrNull { it.first == item.id }?.second == DownloadStatus.Stopped) {
if (downloadFlow.firstOrNull { it.first == item.id }?.second == DownloadStatus.Stopped) {
downloadQueue.remove(item.id, false)
}
stopServiceIfDone()
// start the next download if there are any remaining ones enqueued
val nextDownload = downloadFlow.firstOrNull { (_, status) -> status == DownloadStatus.Paused }
if (nextDownload != null) {
resume(nextDownload.first)
} else {
stopServiceIfDone()
}
}
private suspend fun progressDownload(