diff --git a/ConversationsClassic/AppCore/Files/DownloadManager.swift b/ConversationsClassic/AppCore/Files/DownloadManager.swift index 0df85f9..67bf06e 100644 --- a/ConversationsClassic/AppCore/Files/DownloadManager.swift +++ b/ConversationsClassic/AppCore/Files/DownloadManager.swift @@ -25,18 +25,20 @@ final class DownloadManager { self.downloadQueue.async { self.activeDownloads.remove(url) - if let tempLocalUrl = tempLocalUrl, error == nil { - 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 { + guard let tempLocalUrl = tempLocalUrl, error == nil else { 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) } } }