Skip to content

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

:art: Improve checking for updates on exit https://github.com/siyuan-note/siyuan/issues/13608

Daniele24a46200300
diff --git a/app/electron/main.js b/app/electron/main.js
index 7732a60183..83b0d1831d 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -1007,6 +1007,17 @@ app.whenReady().then(() => {
ipcMain.on("siyuan-quit", (event, port) => {
exitApp(port);
});
+ ipcMain.on("siyuan-show-window", (event) => {
+ const mainWindow = getWindowByContentId(event.sender.id);
+ if (!mainWindow) {
+ return;
+ }
+
+ if (mainWindow.isMinimized()) {
+ mainWindow.restore();
+ }
+ mainWindow.show();
+ });
ipcMain.on("siyuan-open-window", (event, data) => {
const mainWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
const mainBounds = mainWindow.getBounds();
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 99864690c8..c4b4b1151f 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -57,6 +57,8 @@ export abstract class Constants {
public static readonly SIYUAN_CONTEXT_MENU: string = "siyuan-context-menu";
+ public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
+
// custom
public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth";
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index b341822534..06fb321191 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -310,6 +310,11 @@ export const exitSiYuan = async () => {
}
} else if (response.code === 2) { // 提示新安装包
hideMessage();
+
+ if ("std" === window.siyuan.config.system.container) {
+ ipcRenderer.send(Constants.SIYUAN_SHOW_WINDOW);
+ }
+
confirmDialog(window.siyuan.languages.tip, response.msg, () => {
fetchPost("/api/system/exit", {
force: true,
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index e95117c47f..56ec3b2647 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -629,19 +629,17 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
util.IsExiting.Store(true)
waitSecondForExecInstallPkg := false
- if !skipNewVerInstallPkg() {
- if newVerInstallPkgPath := getNewVerInstallPkgPath(); "" != newVerInstallPkgPath {
- if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
- waitSecondForExecInstallPkg = true
- if gulu.OS.IsWindows() {
- util.PushMsg(Conf.Language(130), 1000*30)
- }
- go execNewVerInstallPkg(newVerInstallPkgPath)
- } else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
- exitCode = 2
- logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
- return
+ if !skipNewVerInstallPkg() && "" != newVerInstallPkgPath {
+ if 2 == execInstallPkg || (force && 0 == execInstallPkg) { // 执行新版本安装
+ waitSecondForExecInstallPkg = true
+ if gulu.OS.IsWindows() {
+ util.PushMsg(Conf.Language(130), 1000*30)
}
+ go execNewVerInstallPkg(newVerInstallPkgPath)
+ } else if 0 == execInstallPkg { // 新版本安装包已经准备就绪
+ exitCode = 2
+ logging.LogInfof("the new version install pkg is ready [%s], waiting for the user's next instruction", newVerInstallPkgPath)
+ return
}
}
diff --git a/kernel/model/updater.go b/kernel/model/updater.go
index f902b49d6b..83f2a393fa 100644
--- a/kernel/model/updater.go
+++ b/kernel/model/updater.go
@@ -54,23 +54,28 @@ func execNewVerInstallPkg(newVerInstallPkgPath string) {
}
}
+var newVerInstallPkgPath string
+
func getNewVerInstallPkgPath() string {
if skipNewVerInstallPkg() {
+ newVerInstallPkgPath = ""
return ""
}
downloadPkgURLs, checksum, err := getUpdatePkg()
if err != nil || 1 > len(downloadPkgURLs) || "" == checksum {
+ newVerInstallPkgPath = ""
return ""
}
pkg := path.Base(downloadPkgURLs[0])
- ret := filepath.Join(util.TempDir, "install", pkg)
- localChecksum, _ := sha256Hash(ret)
+ newVerInstallPkgPath = filepath.Join(util.TempDir, "install", pkg)
+ localChecksum, _ := sha256Hash(newVerInstallPkgPath)
if checksum != localChecksum {
+ newVerInstallPkgPath = ""
return ""
}
- return ret
+ return newVerInstallPkgPath
}
var checkDownloadInstallPkgLock = sync.Mutex{}