Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 桌面端自动下载更新安装包 https://github.com/siyuan-note/siyuan/issues/5837

Liang Ding395eeb6cdb76
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index 12acd68482..017b27e59a 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -19,7 +19,6 @@ package model
import (
"bytes"
"os"
- "os/exec"
"path/filepath"
"runtime"
"sort"
@@ -389,22 +388,7 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
}
if 2 == execInstallPkg && "" != newVerInstallPkgPath { // 执行新版本安装
- logging.LogInfof("installing the new version [%s]", newVerInstallPkgPath)
- var cmd *exec.Cmd
- if gulu.OS.IsWindows() {
- cmd = exec.Command(newVerInstallPkgPath)
- } else if gulu.OS.IsDarwin() {
- cmd = exec.Command("open", newVerInstallPkgPath)
- } else if gulu.OS.IsLinux() {
- cmd = exec.Command("sh", "-c", 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)
+ execNewVerInstallPkg(newVerInstallPkgPath)
}
}
diff --git a/kernel/model/updater.go b/kernel/model/updater.go
index b3db3cd6a1..fb5270928e 100644
--- a/kernel/model/updater.go
+++ b/kernel/model/updater.go
@@ -22,6 +22,7 @@ import (
"fmt"
"io"
"os"
+ "os/exec"
"path"
"path/filepath"
"runtime"
@@ -34,6 +35,25 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
+func execNewVerInstallPkg(newVerInstallPkgPath string) {
+ logging.LogInfof("installing the new version [%s]", newVerInstallPkgPath)
+ var cmd *exec.Cmd
+ if gulu.OS.IsWindows() {
+ cmd = exec.Command(newVerInstallPkgPath)
+ } else if gulu.OS.IsDarwin() {
+ cmd = exec.Command("open", newVerInstallPkgPath)
+ } else if gulu.OS.IsLinux() {
+ cmd = exec.Command("sh", "-c", newVerInstallPkgPath)
+ }
+ util.CmdAttr(cmd)
+ data, cmdErr := cmd.CombinedOutput()
+ if nil != cmdErr {
+ logging.LogErrorf("exec install new version failed: %s", cmdErr)
+ return
+ }
+ logging.LogInfof("installed new version output [%s]", data)
+}
+
func GetNewVerInstallPkgPath() string {
if skipNewVerInstallPkg() {
return ""