This commit is contained in:
Daniel 2024-12-25 21:59:10 +08:00
parent 746226054a
commit e24a462003
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 36 additions and 15 deletions

View file

@ -629,19 +629,17 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
util.IsExiting.Store(true)
waitSecondForExecInstallPkg := false
if !skipNewVerInstallPkg() {
if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
waitSecondForExecInstallPkg = true
if gulu.OS.IsWindows() {
util.PushMsg(Conf.Language(130), 1000*30)
}
go execNewVerInstallPkg(newVerInstallPkgPath)
} else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
exitCode = 2
logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
return
if !skipNewVerInstallPkg() && "" != newVerInstallPkgPath {
if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
waitSecondForExecInstallPkg = true
if gulu.OS.IsWindows() {
util.PushMsg(Conf.Language(130), 1000*30)
}
go execNewVerInstallPkg(newVerInstallPkgPath)
} else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
exitCode = 2
logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
return
}
}

View file

@ -54,23 +54,28 @@ func execNewVerInstallPkg(newVerInstallPkgPath string) {
}
}
var newVerInstallPkgPath string
func getNewVerInstallPkgPath() string {
if skipNewVerInstallPkg() {
newVerInstallPkgPath = ""
return ""
}
downloadPkgURLs, checksum, err := getUpdatePkg()
if err != nil || 1 > len(downloadPkgURLs) || "" == checksum {
newVerInstallPkgPath = ""
return ""
}
pkg := path.Base(downloadPkgURLs[0])
ret := filepath.Join(util.TempDir, "install", pkg)
localChecksum, _ := sha256Hash(ret)
newVerInstallPkgPath = filepath.Join(util.TempDir, "install", pkg)
localChecksum, _ := sha256Hash(newVerInstallPkgPath)
if checksum != localChecksum {
newVerInstallPkgPath = ""
return ""
}
return ret
return newVerInstallPkgPath
}
var checkDownloadInstallPkgLock = sync.Mutex{}