🐛 桌面端拉起自动更新安装包偶尔失败 Fix https://github.com/siyuan-note/siyuan/issues/5996

This commit is contained in:
Liang Ding 2022-09-28 11:38:40 +08:00
parent da392ba0d2
commit 400fc166b2
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 6 additions and 2 deletions

View file

@ -379,6 +379,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
// return true
//})
waitSecondForExecInstallPkg := false
if !skipNewVerInstallPkg() {
newVerInstallPkgPath := getNewVerInstallPkgPath()
if "" != newVerInstallPkgPath {
@ -387,6 +388,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
return
} else if 2 == execInstallPkg { // 执行新版本安装
waitSecondForExecInstallPkg = true
go execNewVerInstallPkg(newVerInstallPkgPath)
}
}
@ -398,6 +400,9 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
go func() {
time.Sleep(500 * time.Millisecond)
if waitSecondForExecInstallPkg {
time.Sleep(1 * time.Second)
}
logging.LogInfof("exited kernel")
util.WebSocketServer.Close()
os.Exit(util.ExitCodeOk)

View file

@ -46,12 +46,11 @@ func execNewVerInstallPkg(newVerInstallPkgPath string) {
cmd = exec.Command("sh", "-c", newVerInstallPkgPath)
}
util.CmdAttr(cmd)
data, cmdErr := cmd.CombinedOutput()
cmdErr := cmd.Start()
if nil != cmdErr {
logging.LogErrorf("exec install new version failed: %s", cmdErr)
return
}
logging.LogInfof("installed new version output [%s]", data)
}
func getNewVerInstallPkgPath() string {