mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-09 08:13:29 +08:00
- 安装更新前先确认关闭当前安装目录下的 GoNavi 实例,并继续执行未保存 SQL 退出保护 - 按可执行文件路径枚举并复核进程身份,优雅关闭超时后再强制终止,避免 PID 复用误杀 - 通过全局维护事件阻止更新期间启动新实例,并由 PowerShell 更新器完成跨权限无空窗交接 - 同步更新前端交互、多语言提示、Wails 绑定及 Windows 发布资产校验
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package app
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func otherWindowsUpdateProcessIDs(processes []windowsUpdateProcess) []uint32 {
|
|
result := make([]uint32, 0, len(processes))
|
|
for _, process := range processes {
|
|
result = append(result, process.PID)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func windowsUpdateCloseConfirmationRequired(goos string, confirmed bool) bool {
|
|
return strings.EqualFold(strings.TrimSpace(goos), "windows") && !confirmed
|
|
}
|
|
|
|
func closeOtherWindowsUpdateInstancesForInstall(targetPaths []string, currentPID int) ([]uint32, error) {
|
|
instances, err := updateFindOtherWindowsInstances(targetPaths, currentPID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
pids := otherWindowsUpdateProcessIDs(instances)
|
|
if len(instances) == 0 {
|
|
return pids, nil
|
|
}
|
|
if err := updateCloseWindowsInstances(instances); err != nil {
|
|
return pids, err
|
|
}
|
|
remaining, err := updateFindOtherWindowsInstances(targetPaths, currentPID)
|
|
if err != nil {
|
|
return pids, err
|
|
}
|
|
if len(remaining) > 0 {
|
|
return pids, fmt.Errorf("GoNavi processes still running after close: %v", otherWindowsUpdateProcessIDs(remaining))
|
|
}
|
|
return pids, nil
|
|
}
|