🐛 桌面端拉起自动更新安装包偶尔失败 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 // return true
//}) //})
waitSecondForExecInstallPkg := false
if !skipNewVerInstallPkg() { if !skipNewVerInstallPkg() {
newVerInstallPkgPath := getNewVerInstallPkgPath() newVerInstallPkgPath := getNewVerInstallPkgPath()
if "" != newVerInstallPkgPath { 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) logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
return return
} else if 2 == execInstallPkg { // 执行新版本安装 } else if 2 == execInstallPkg { // 执行新版本安装
waitSecondForExecInstallPkg = true
go execNewVerInstallPkg(newVerInstallPkgPath) go execNewVerInstallPkg(newVerInstallPkgPath)
} }
} }
@ -398,6 +400,9 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
go func() { go func() {
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
if waitSecondForExecInstallPkg {
time.Sleep(1 * time.Second)
}
logging.LogInfof("exited kernel") logging.LogInfof("exited kernel")
util.WebSocketServer.Close() util.WebSocketServer.Close()
os.Exit(util.ExitCodeOk) os.Exit(util.ExitCodeOk)

View file

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