Skip to content

mark Downloader as deprecated #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Sources/TSCUtility/Downloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import FoundationNetworking
#endif

/// Error enumeration that can be returned by a `Downloader` conforming type.
// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
public enum DownloaderError: Error {

/// Error thrown when the downloader fails to establish a connection to the server.
Expand All @@ -28,6 +30,8 @@ public enum DownloaderError: Error {
}

/// The `Downloader` protocol abstract away the download of a file with a progress report.
// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
public protocol Downloader {

/// The progress closure type. The first arguments contains the number of bytes downloaded, and the second argument
Expand Down Expand Up @@ -55,6 +59,8 @@ public protocol Downloader {
)
}

// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
extension DownloaderError: LocalizedError {
public var errorDescription: String? {
switch self {
Expand All @@ -69,6 +75,8 @@ extension DownloaderError: LocalizedError {
}

/// A `Downloader` conformance that uses Foundation's `URLSession`.
// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
public final class FoundationDownloader: NSObject, Downloader {

/// The integer identifier of a `URLSessionTask`.
Expand Down Expand Up @@ -134,6 +142,8 @@ public final class FoundationDownloader: NSObject, Downloader {
}
}

// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
extension FoundationDownloader: URLSessionDownloadDelegate {
public func urlSession(
_ session: URLSession,
Expand Down Expand Up @@ -177,6 +187,8 @@ extension FoundationDownloader: URLSessionDownloadDelegate {
}
}

// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
extension FoundationDownloader {

/// Returns the download data structure associated with a task and fails if none is found as this should never
Expand All @@ -191,6 +203,8 @@ extension FoundationDownloader {
}
}

// deprecated 2/2021
@available(*, deprecated, message: "moved to SwiftPM, use URLSession or async-http-client instead")
extension FoundationDownloader.Download {
func notifyProgress(bytesDownloaded: Int64, totalBytesToDownload: Int64?) {
DispatchQueue.global().async {
Expand Down
2 changes: 2 additions & 0 deletions Tests/TSCUtilityTests/DownloaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import Foundation
import FoundationNetworking
#endif

// deprecated 2/2021
@available(*, deprecated)
class DownloaderTests: XCTestCase {

func testSuccess() throws {
Expand Down