浏览代码

Added docstrings and note to README about resumeData and background sessions.

Christian Noon 9 年之前
父节点
当前提交
4af61a695b
共有 3 个文件被更改,包括 16 次插入0 次删除
  1. 2 0
      README.md
  2. 7 0
      Source/Alamofire.swift
  3. 7 0
      Source/SessionManager.swift

+ 2 - 0
README.md

@@ -672,6 +672,8 @@ Alamofire.download("https://httpbin.org/image/png")
 
 If a `DownloadRequest` is cancelled or interrupted, the underlying URL session may generate resume data for the active `DownloadRequest`. If this happens, the resume data can be re-used to restart the `DownloadRequest` where it left off. The resume data can be accessed through the download response, then reused when trying to restart the request.
 
+> **IMPORTANT:** On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the data is written incorrectly and will always fail to resume the download. For more information about the bug and possible workarounds, please see this Stack Overflow [post](http://stackoverflow.com/a/39347461/1342462).
+
 ```swift
 class ImageRequestor {
 	private var resumeData: Data?

+ 7 - 0
Source/Alamofire.swift

@@ -222,6 +222,13 @@ public func download(
 /// If `destination` is not specified, the contents will remain in the temporary location determined by the
 /// underlying URL session.
 ///
+/// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken 
+/// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the 
+/// data is written incorrectly and will always fail to resume the download. For more information about the bug and 
+/// possible workarounds, please refer to the following Stack Overflow post:
+///
+///    - http://stackoverflow.com/a/39347461/1342462
+///
 /// - parameter resumeData:  The resume data. This is an opaque data blob produced by `URLSessionDownloadTask`
 ///                          when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for additional
 ///                          information.

+ 7 - 0
Source/SessionManager.swift

@@ -348,6 +348,13 @@ open class SessionManager {
     ///
     /// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
     ///
+    /// On the latest release of all the Apple platforms (iOS 10, macOS 10.12, tvOS 10, watchOS 3), `resumeData` is broken
+    /// on background URL session configurations. There's an underlying bug in the `resumeData` generation logic where the
+    /// data is written incorrectly and will always fail to resume the download. For more information about the bug and
+    /// possible workarounds, please refer to the following Stack Overflow post:
+    ///
+    ///    - http://stackoverflow.com/a/39347461/1342462
+    ///
     /// - parameter resumeData:  The resume data. This is an opaque data blob produced by `URLSessionDownloadTask`
     ///                          when a task is cancelled. See `URLSession -downloadTask(withResumeData:)` for
     ///                          additional information.