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

This commit is contained in:
Liang Ding 2022-09-09 08:51:44 +08:00
parent d49a73b752
commit 395eeb6cdb
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 21 additions and 17 deletions

View file

@ -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)
}
}

View file

@ -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 ""