From 7b16134717714ee4512707974df2c9c232e5fbf4 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 9 Sep 2022 08:45:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=A1=8C=E9=9D=A2=E7=AB=AF=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E8=BD=BD=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8C=85=20https://github.com/siyuan-note/siyuan/issues/5837?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/conf.go | 34 ++++++++++++++++++---------------- kernel/model/updater.go | 17 +++++++++++++++-- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index dfa552a4d..a2709263c 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -378,25 +378,27 @@ func Close(force bool, execInstallPkg int) (exitCode int) { // return true //}) - newVerInstallPkgPath := "" - if Conf.System.DownloadInstallPkg && !util.ISMicrosoftStore { - newVerInstallPkgPath = GetNewVerInstallPkgPath() - if "" != newVerInstallPkgPath && 0 == execInstallPkg { - exitCode = 2 - return + if !skipNewVerInstallPkg() { + newVerInstallPkgPath := "" + if Conf.System.DownloadInstallPkg && !util.ISMicrosoftStore { + newVerInstallPkgPath = GetNewVerInstallPkgPath() + if "" != newVerInstallPkgPath && 0 == execInstallPkg { + exitCode = 2 + return + } } - } - if 2 == execInstallPkg && "" != newVerInstallPkgPath { // 执行新版本安装 - logging.LogInfof("installing the new version [%s]", newVerInstallPkgPath) - cmd := exec.Command(newVerInstallPkgPath) - util.CmdAttr(cmd) - data, cmdErr := cmd.CombinedOutput() - if nil != cmdErr { - logging.LogErrorf("exec install new version failed: %s", cmdErr) - return + if 2 == execInstallPkg && "" != newVerInstallPkgPath { // 执行新版本安装 + logging.LogInfof("installing the new version [%s]", newVerInstallPkgPath) + cmd := exec.Command(newVerInstallPkgPath) + util.CmdAttr(cmd) + data, cmdErr := cmd.CombinedOutput() + if nil != cmdErr { + logging.LogErrorf("exec install new version failed: %s", cmdErr) + return + } + logging.LogDebugf("exec install new version output [%s]", data) } - logging.LogDebugf("exec install new version output [%s]", data) } Conf.Close() diff --git a/kernel/model/updater.go b/kernel/model/updater.go index 02ee254b2..2879bad0c 100644 --- a/kernel/model/updater.go +++ b/kernel/model/updater.go @@ -35,7 +35,7 @@ import ( ) func GetNewVerInstallPkgPath() string { - if !Conf.System.DownloadInstallPkg || util.ISMicrosoftStore { + if skipNewVerInstallPkg() { return "" } @@ -58,7 +58,7 @@ var checkDownloadInstallPkgLock = sync.Mutex{} func checkDownloadInstallPkg() { defer logging.Recover() - if !Conf.System.DownloadInstallPkg || util.ISMicrosoftStore { + if skipNewVerInstallPkg() { return } @@ -217,3 +217,16 @@ func CheckUpdate(showMsg bool) { util.PushMsg(msg, timeout) } } + +func skipNewVerInstallPkg() bool { + if !gulu.OS.IsWindows() { + return true + } + if util.ISMicrosoftStore { + return true + } + if !Conf.System.DownloadInstallPkg { + return true + } + return false +}