Mark delegate methods as nonisolated to fix concurrency warning. Use MainActor.assumeIsolated because we did specify the main queue for these methods.
This commit is contained in:
parent
2c91765896
commit
feb1e77424
@ -86,7 +86,9 @@ public protocol DownloadSessionDelegate {
|
|||||||
|
|
||||||
extension DownloadSession: URLSessionTaskDelegate {
|
extension DownloadSession: URLSessionTaskDelegate {
|
||||||
|
|
||||||
public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
nonisolated public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
||||||
|
|
||||||
|
MainActor.assumeIsolated {
|
||||||
tasksInProgress.remove(task)
|
tasksInProgress.remove(task)
|
||||||
|
|
||||||
guard let info = infoForTask(task) else {
|
guard let info = infoForTask(task) else {
|
||||||
@ -99,9 +101,11 @@ extension DownloadSession: URLSessionTaskDelegate {
|
|||||||
self.removeTask(task)
|
self.removeTask(task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
|
nonisolated public func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
|
||||||
|
|
||||||
|
MainActor.assumeIsolated {
|
||||||
if response.statusCode == 301 || response.statusCode == 308 {
|
if response.statusCode == 301 || response.statusCode == 308 {
|
||||||
if let oldURLString = task.originalRequest?.url?.absoluteString, let newURLString = request.url?.absoluteString {
|
if let oldURLString = task.originalRequest?.url?.absoluteString, let newURLString = request.url?.absoluteString {
|
||||||
cacheRedirect(oldURLString, newURLString)
|
cacheRedirect(oldURLString, newURLString)
|
||||||
@ -111,6 +115,7 @@ extension DownloadSession: URLSessionTaskDelegate {
|
|||||||
completionHandler(request)
|
completionHandler(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - URLSessionDataDelegate
|
// MARK: - URLSessionDataDelegate
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user