diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27edfc9..3838758 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,11 @@ jobs: strategy: fail-fast: false matrix: - xcode: ["13.4.1", "13.3.1", "13.2.1"] + xcode: ["14.1", "13.4.1", "13.2.1"] include: - - xcode: "13.4.1" + - xcode: "14.1" macos: macOS-12 - - xcode: "13.3.1" + - xcode: "13.4.1" macos: macOS-12 - xcode: "13.2.1" macos: macOS-11 @@ -42,16 +42,3 @@ jobs: - uses: actions/checkout@v2 - name: Run Tests run: swift test - - discover-typos: - name: Discover Typos - runs-on: macOS-12 - env: - DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer - steps: - - uses: actions/checkout@v2 - - name: Discover typos - run: | - python3 -m pip install --upgrade pip - python3 -m pip install codespell - codespell --ignore-words-list="inout,theis" --skip="./.git,./.build/*,./Tests/GetTests/Mocker/*" diff --git a/Sources/Get/DataLoader.swift b/Sources/Get/DataLoader.swift index 99cfea0..5a53475 100644 --- a/Sources/Get/DataLoader.swift +++ b/Sources/Get/DataLoader.swift @@ -29,7 +29,7 @@ final class DataLoader: NSObject, URLSessionDataDelegate, URLSessionDownloadDele }() func startDataTask(_ task: URLSessionDataTask, session: URLSession, delegate: URLSessionDataDelegate?) async throws -> Response { - try await withTaskCancellationHandler(handler: { task.cancel() }) { + try await withTaskCancellationHandler(operation: { try await withUnsafeThrowingContinuation { continuation in let handler = DataTaskHandler(delegate: delegate) handler.completion = continuation.resume(with:) @@ -37,11 +37,13 @@ final class DataLoader: NSObject, URLSessionDataDelegate, URLSessionDownloadDele task.resume() } - } + }, onCancel: { + task.cancel() + }) } func startDownloadTask(_ task: URLSessionDownloadTask, session: URLSession, delegate: URLSessionDownloadDelegate?) async throws -> Response { - try await withTaskCancellationHandler(handler: { task.cancel() }) { + try await withTaskCancellationHandler(operation: { try await withUnsafeThrowingContinuation { continuation in let handler = DownloadTaskHandler(delegate: delegate) handler.completion = continuation.resume(with:) @@ -49,11 +51,13 @@ final class DataLoader: NSObject, URLSessionDataDelegate, URLSessionDownloadDele task.resume() } - } + }, onCancel: { + task.cancel() + }) } func startUploadTask(_ task: URLSessionUploadTask, session: URLSession, delegate: URLSessionTaskDelegate?) async throws -> Response { - try await withTaskCancellationHandler(handler: { task.cancel() }) { + try await withTaskCancellationHandler(operation: { try await withUnsafeThrowingContinuation { continuation in let handler = DataTaskHandler(delegate: delegate) handler.completion = continuation.resume(with:) @@ -61,7 +65,9 @@ final class DataLoader: NSObject, URLSessionDataDelegate, URLSessionDownloadDele task.resume() } - } + }, onCancel: { + task.cancel() + }) } // MARK: - URLSessionDelegate