Skip to content

Commit

Permalink
v4.2.2 改进检查 app 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
yanue committed Jul 7, 2024
1 parent ba8e473 commit dbb68a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
8 changes: 4 additions & 4 deletions V2rayU.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)";
Expand All @@ -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;
Expand All @@ -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)";
Expand Down
32 changes: 24 additions & 8 deletions V2rayU/AppVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down Expand Up @@ -550,7 +550,7 @@ class AppDownloadController: NSWindowController, URLSessionDownloadDelegate {
}
}

print("Installing V2rayU")
print("Installing V2rayU: \(String(describing: self.destinationURL))")
}

// ---------------------- ui 相关 --------------------------------
Expand Down Expand Up @@ -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)")
Expand Down

0 comments on commit dbb68a9

Please sign in to comment.