Explorar o código

Add automaticallyCancelling parameter to serializingDownloadedFileURL (#3597)

Jon Shier %!s(int64=3) %!d(string=hai) anos
pai
achega
824ce8bd36
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      Source/Concurrency.swift

+ 8 - 2
Source/Concurrency.swift

@@ -413,9 +413,15 @@ extension DownloadRequest {
 
     /// Creates a `DownloadTask` to `await` serialization of the downloaded file's `URL` on disk.
     ///
+    /// - Parameters:
+    ///   - shouldAutomaticallyCancel: `Bool` determining whether or not the request should be cancelled when the
+    ///                                enclosing async context is cancelled. Only applies to `DownloadTask`'s async
+    ///                                properties. `false` by default.
+    ///
     /// - Returns: The `DownloadTask`.
-    public func serializingDownloadedFileURL() -> DownloadTask<URL> {
-        serializingDownload(using: URLResponseSerializer())
+    public func serializingDownloadedFileURL(automaticallyCancelling shouldAutomaticallyCancel: Bool = false) -> DownloadTask<URL> {
+        serializingDownload(using: URLResponseSerializer(),
+                            automaticallyCancelling: shouldAutomaticallyCancel)
     }
 
     /// Creates a `DownloadTask` to `await` serialization of a `String` value.