diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt index f3866408833..b5ea9a2415d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt @@ -198,8 +198,15 @@ object DownloadQueueManager { } } - /** Removes all queued items */ + /** Cancel and remove all inactive downloads */ fun removeAllFromQueue() { + downloadInstances.value + .filter { + val status = downloadStatus[it.downloadQueueWrapper.id] + status != VideoDownloadManager.DownloadType.IsDownloading && status != VideoDownloadManager.DownloadType.IsPaused + } + .forEach { it.cancelDownload() } + removeAll().forEach { wrapper -> setQueueStatus(wrapper.id, VideoDownloadManager.DownloadType.IsStopped) } @@ -247,4 +254,4 @@ object DownloadQueueManager { localQueue.copyOf() } } -} \ No newline at end of file +}