From d436171a2f89f58107d5bc48d2a6be2fbb8845eb Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Wed, 23 Aug 2023 06:36:43 +0200 Subject: [PATCH] removed possible duplicate download queue --- .../lagradost/cloudstream3/utils/VideoDownloadManager.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt index 37c02be4..442fa32f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt @@ -1598,9 +1598,8 @@ object VideoDownloadManager { val item = pkg.item val id = item.ep.id if (currentDownloads.contains(id)) { // IF IT IS ALREADY DOWNLOADING, RESUME IT - downloadEvent.invoke(Pair(id, DownloadActionType.Resume)) - /** ID needs to be returned to the work-manager to properly await notification */ - // return id + downloadEvent.invoke(id to DownloadActionType.Resume) + return } currentDownloads.add(id) @@ -1741,14 +1740,14 @@ object VideoDownloadManager { notificationCallback: (Int, Notification) -> Unit, setKey: Boolean = true ) { - if (!currentDownloads.any { it == pkg.item.ep.id }) { + if (!currentDownloads.any { it == pkg.item.ep.id } && !downloadQueue.any { it.item.ep.id == pkg.item.ep.id }) { downloadQueue.addLast(pkg) downloadCheck(context, notificationCallback) if (setKey) saveQueue() //ret } else { downloadEvent( - Pair(pkg.item.ep.id, DownloadActionType.Resume) + pkg.item.ep.id to DownloadActionType.Resume ) //null }