Update Alamofire to 4.2.0 with new version of Xcode 8.1

This commit is contained in:
Vicent Tsai
2016-12-11 17:17:36 +08:00
parent 23967eca20
commit 4dd3bd495e
37 changed files with 1192 additions and 769 deletions

View File

@ -33,13 +33,16 @@ open class TaskDelegate: NSObject {
/// The serial operation queue used to execute all operations after the task completes.
open let queue: OperationQueue
/// The data returned by the server.
public var data: Data? { return nil }
/// The error generated throughout the lifecyle of the task.
public var error: Error?
var task: URLSessionTask? {
didSet { reset() }
}
var data: Data? { return nil }
var error: Error?
var initialResponseTime: CFAbsoluteTime?
var credential: URLCredential?
var metrics: AnyObject? // URLSessionTaskMetrics
@ -331,29 +334,30 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
{
temporaryURL = location
if let destination = destination {
let result = destination(location, downloadTask.response as! HTTPURLResponse)
let destination = result.destinationURL
let options = result.options
guard
let destination = destination,
let response = downloadTask.response as? HTTPURLResponse
else { return }
do {
destinationURL = destination
let result = destination(location, response)
let destinationURL = result.destinationURL
let options = result.options
if options.contains(.removePreviousFile) {
if FileManager.default.fileExists(atPath: destination.path) {
try FileManager.default.removeItem(at: destination)
}
}
self.destinationURL = destinationURL
if options.contains(.createIntermediateDirectories) {
let directory = destination.deletingLastPathComponent()
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true, attributes: nil)
}
try FileManager.default.moveItem(at: location, to: destination)
} catch {
self.error = error
do {
if options.contains(.removePreviousFile), FileManager.default.fileExists(atPath: destinationURL.path) {
try FileManager.default.removeItem(at: destinationURL)
}
if options.contains(.createIntermediateDirectories) {
let directory = destinationURL.deletingLastPathComponent()
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
}
try FileManager.default.moveItem(at: location, to: destinationURL)
} catch {
self.error = error
}
}