diff --git a/V2rayU.xcodeproj/project.pbxproj b/V2rayU.xcodeproj/project.pbxproj index 6a5ffd5..521ecca 100755 --- a/V2rayU.xcodeproj/project.pbxproj +++ b/V2rayU.xcodeproj/project.pbxproj @@ -840,7 +840,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4.2.0; + CURRENT_PROJECT_VERSION = 4.2.2; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; ENABLE_ONLY_ACTIVE_RESOURCES = YES; @@ -851,7 +851,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 4.2.1; + MARKETING_VERSION = 4.2.2; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = net.yanue.V2rayU; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -875,7 +875,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4.2.0; + CURRENT_PROJECT_VERSION = 4.2.2; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; ENABLE_ONLY_ACTIVE_RESOURCES = YES; @@ -886,7 +886,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 4.2.1; + MARKETING_VERSION = 4.2.2; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = net.yanue.V2rayU; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/V2rayU/AppVersion.swift b/V2rayU/AppVersion.swift index c4a040c..b312de0 100644 --- a/V2rayU/AppVersion.swift +++ b/V2rayU/AppVersion.swift @@ -308,7 +308,7 @@ class AppVersionController: NSWindowController { func show(release: GithubRelease) { DispatchQueue.main.async { self.release = release - if isMainland { + if !isMainland { self.bindData.title = "A new version of V2rayU is available!" if release.prerelease{ self.bindData.description = "V2rayU \(release.tagName) preview is now available, you have \(appVersion). Would you like to download it now?" @@ -550,7 +550,7 @@ class AppDownloadController: NSWindowController, URLSessionDownloadDelegate { } } - print("Installing V2rayU") + print("Installing V2rayU: \(String(describing: self.destinationURL))") } // ---------------------- ui 相关 -------------------------------- @@ -618,27 +618,43 @@ class AppDownloadController: NSWindowController, URLSessionDownloadDelegate { func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { let fileManager = FileManager.default let downloadsDirectory = fileManager.urls(for: .downloadsDirectory, in: .userDomainMask).first! - destinationURL = downloadsDirectory.appendingPathComponent(downloadTask.response?.suggestedFilename ?? "V2rayU-macOS.dmg") - + let destUrl = downloadsDirectory.appendingPathComponent(downloadTask.response?.suggestedFilename ?? "V2rayU-macOS.dmg") + do { - try fileManager.moveItem(at: location, to: destinationURL!) + print("destinationURL: \(destUrl)") + if fileManager.fileExists(atPath: destUrl.path) { + print("Download file already exists: \(destUrl.path) \(location)") + DispatchQueue.main.async { + self.bindData.isDownloading = false + self.bindData.progress = 100.0 + self.bindData.progressText = "Download Completed" + self.destinationURL = destUrl + } + return + } + + try fileManager.moveItem(at: location, to: destUrl) + DispatchQueue.main.async { self.bindData.isDownloading = false self.bindData.progress = 100.0 self.bindData.progressText = "Download Completed" + self.destinationURL = destUrl } - print("Download finished: \(destinationURL!)") + + print("Download finished: \(destUrl)") } catch { DispatchQueue.main.async { self.bindData.isDownloading = false self.bindData.progressText = "File move error: \(error.localizedDescription)" + self.destinationURL = destUrl var title = "Download failed!" var toast = "\(error)" if isMainland { title = "移动文件失败" - toast = "\(error)"; + toast = "\(error)" } - // open dialog + // Ensure alertDialog function displays an alert to the user alertDialog(title: title, message: toast) } print("File move error: \(error.localizedDescription)")