From 9f5184c21d1c09ff6a9f390f71763e210e3511a9 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Mon, 17 Feb 2025 13:58:11 +0100 Subject: [PATCH] fix --- .../ios/HlsDownloaderModule.swift | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/modules/hls-downloader/ios/HlsDownloaderModule.swift b/modules/hls-downloader/ios/HlsDownloaderModule.swift index 4788ce50..7ebe0db2 100644 --- a/modules/hls-downloader/ios/HlsDownloaderModule.swift +++ b/modules/hls-downloader/ios/HlsDownloaderModule.swift @@ -8,13 +8,6 @@ public class HlsDownloaderModule: Module { startTime: Double )] = [:] - struct DownloadRequest { - let providedId: String - let url: String - let metadata: [String: Any]? - } - var pendingDownloads: [DownloadRequest] = [] - public func definition() -> ModuleDefinition { Name("HlsDownloader") @@ -24,22 +17,6 @@ public class HlsDownloaderModule: Module { (providedId: String, url: String, metadata: [String: Any]?) -> Void in let startTime = Date().timeIntervalSince1970 - // Enforce max 3 concurrent downloads. - if self.activeDownloads.count >= 3 { - self.pendingDownloads.append( - DownloadRequest(providedId: providedId, url: url, metadata: metadata)) - self.sendEvent( - "onProgress", - [ - "id": providedId, - "progress": 0.0, - "state": "QUEUED", - "metadata": metadata ?? [:], - "startTime": startTime, - ]) - return - } - // First check if the asset already exists let fm = FileManager.default let docs = fm.urls(for: .documentDirectory, in: .userDomainMask)[0] @@ -151,9 +128,7 @@ public class HlsDownloaderModule: Module { } delegate.taskIdentifier = task.taskIdentifier - self.activeDownloads[task.taskIdentifier] = (task, delegate, metadata ?? [:], startTime) - self.sendEvent( "onProgress", [ @@ -201,7 +176,8 @@ public class HlsDownloaderModule: Module { print("No active download found with identifier: \(providedId)") return } - let (task, _, metadata, startTime) = entry.value + let (task, delegate, metadata, startTime) = entry.value + self.sendEvent( "onError", [ @@ -211,6 +187,7 @@ public class HlsDownloaderModule: Module { "metadata": metadata, "startTime": startTime, ]) + task.cancel() self.activeDownloads.removeValue(forKey: task.taskIdentifier) print("Download cancelled for identifier: \(providedId)")