removed possible duplicate download queue

This commit is contained in:
LagradOst 2023-08-23 06:36:43 +02:00
parent 3ea6b1a8d5
commit d436171a2f
1 changed files with 4 additions and 5 deletions

View File

@ -1598,9 +1598,8 @@ object VideoDownloadManager {
val item = pkg.item val item = pkg.item
val id = item.ep.id val id = item.ep.id
if (currentDownloads.contains(id)) { // IF IT IS ALREADY DOWNLOADING, RESUME IT if (currentDownloads.contains(id)) { // IF IT IS ALREADY DOWNLOADING, RESUME IT
downloadEvent.invoke(Pair(id, DownloadActionType.Resume)) downloadEvent.invoke(id to DownloadActionType.Resume)
/** ID needs to be returned to the work-manager to properly await notification */ return
// return id
} }
currentDownloads.add(id) currentDownloads.add(id)
@ -1741,14 +1740,14 @@ object VideoDownloadManager {
notificationCallback: (Int, Notification) -> Unit, notificationCallback: (Int, Notification) -> Unit,
setKey: Boolean = true 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) downloadQueue.addLast(pkg)
downloadCheck(context, notificationCallback) downloadCheck(context, notificationCallback)
if (setKey) saveQueue() if (setKey) saveQueue()
//ret //ret
} else { } else {
downloadEvent( downloadEvent(
Pair(pkg.item.ep.id, DownloadActionType.Resume) pkg.item.ep.id to DownloadActionType.Resume
) )
//null //null
} }