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