|
@@ -175,6 +175,15 @@ class KMAITranslationVC: NSViewController {
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+ let destinationURL = FileManager.default.temporaryDirectory.appendingPathComponent(downFileName)
|
|
|
+ if FileManager.default.fileExists(atPath: destinationURL.path) {
|
|
|
+ do {
|
|
|
+ try FileManager.default.removeItem(at: destinationURL)
|
|
|
+ print("删除旧文件成功")
|
|
|
+ } catch {
|
|
|
+ print("删除旧文件失败:\(error)")
|
|
|
+ }
|
|
|
+ }
|
|
|
let sessionConfiguration = URLSessionConfiguration.default
|
|
|
let session = URLSession(configuration: sessionConfiguration)
|
|
|
let downloadTask = session.downloadTask(with: fileURL) { (tempLocalURL, response, error) in
|
|
@@ -196,7 +205,6 @@ class KMAITranslationVC: NSViewController {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- let destinationURL = FileManager.default.temporaryDirectory.appendingPathComponent(downFileName)
|
|
|
|
|
|
do {
|
|
|
try FileManager.default.moveItem(at: tempLocalURL, to: destinationURL)
|