wip
This commit is contained in:
parent
86745dc87d
commit
3756dfa527
|
@ -25,18 +25,20 @@ 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 {
|
||||||
do {
|
|
||||||
if FileManager.default.fileExists(atPath: localUrl.path) {
|
|
||||||
try FileManager.default.removeItem(at: localUrl)
|
|
||||||
}
|
|
||||||
try FileManager.default.moveItem(at: tempLocalUrl, to: localUrl)
|
|
||||||
completion(nil)
|
|
||||||
} catch let writeError {
|
|
||||||
completion(writeError)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
completion(error)
|
completion(error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
if FileManager.default.fileExists(atPath: localUrl.path) {
|
||||||
|
try FileManager.default.removeItem(at: localUrl)
|
||||||
|
}
|
||||||
|
let data = try Data(contentsOf: tempLocalUrl)
|
||||||
|
try data.write(to: localUrl)
|
||||||
|
completion(nil)
|
||||||
|
} catch let writeError {
|
||||||
|
completion(writeError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue