diff --git a/Sources/Hub/Downloader.swift b/Sources/Hub/Downloader.swift index 173c2dca..40087a64 100644 --- a/Sources/Hub/Downloader.swift +++ b/Sources/Hub/Downloader.swift @@ -6,7 +6,6 @@ // See LICENSE at https://github.com/huggingface/swift-coreml-diffusers/LICENSE // -import Combine import Foundation /// A robust file downloader with support for resumable downloads and progress reporting. @@ -14,7 +13,7 @@ import Foundation /// The Downloader class handles file downloads from remote URLs with features including /// automatic resume capability, progress tracking, speed monitoring, and retry mechanisms. /// It supports both foreground and background download sessions for different use cases. -final class Downloader: NSObject, Sendable, ObservableObject { +final class Downloader: NSObject, Sendable { private let destination: URL private let incompleteDestination: URL private let downloadResumeState: DownloadResumeState = .init() diff --git a/Sources/Hub/HubApi.swift b/Sources/Hub/HubApi.swift index 7fd54baa..3a4d8a04 100644 --- a/Sources/Hub/HubApi.swift +++ b/Sources/Hub/HubApi.swift @@ -491,9 +491,10 @@ public extension HubApi { } } - /// Note we go from Combine in Downloader to callback-based progress reporting - /// We'll probably need to support Combine as well to play well with Swift UI - /// (See for example PipelineLoader in swift-coreml-diffusers) + /// Downloads the file with progress tracking. + /// - Parameter progressHandler: Called with download progress (0.0-1.0) and speed in bytes/sec, if available. + /// - Returns: Local file URL (uses cached file if commit hash matches). + /// - Throws: ``EnvironmentError`` errors for file and metadata validation failures, ``Downloader.DownloadError`` errors during transfer, or ``CancellationError`` if the task is cancelled. @discardableResult func download(progressHandler: @escaping (Double, Double?) -> Void) async throws -> URL { let localMetadata = try hub.readDownloadMetadata(metadataPath: metadataDestination) diff --git a/Tests/HubTests/DownloaderTests.swift b/Tests/HubTests/DownloaderTests.swift index 552fbf3e..eed64ae4 100644 --- a/Tests/HubTests/DownloaderTests.swift +++ b/Tests/HubTests/DownloaderTests.swift @@ -5,7 +5,6 @@ // Created by Arda Atahan Ibis on 1/28/25. // -import Combine import XCTest @testable import Hub