wip
This commit is contained in:
parent
86745dc87d
commit
3756dfa527
|
@ -25,19 +25,21 @@ final class DownloadManager {
|
|||
self.downloadQueue.async {
|
||||
self.activeDownloads.remove(url)
|
||||
|
||||
if let tempLocalUrl = tempLocalUrl, error == nil {
|
||||
guard let tempLocalUrl = tempLocalUrl, error == nil else {
|
||||
completion(error)
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
if FileManager.default.fileExists(atPath: localUrl.path) {
|
||||
try FileManager.default.removeItem(at: localUrl)
|
||||
}
|
||||
try FileManager.default.moveItem(at: tempLocalUrl, to: localUrl)
|
||||
let data = try Data(contentsOf: tempLocalUrl)
|
||||
try data.write(to: localUrl)
|
||||
completion(nil)
|
||||
} catch let writeError {
|
||||
completion(writeError)
|
||||
}
|
||||
} else {
|
||||
completion(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
task.resume()
|
||||
|
|
Loading…
Reference in a new issue