mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-12 01:24:12 +08:00
统一 macOS、Windows 和 Linux 更新包到用户缓存目录,失败时回退系统临时目录。成功更新后清理整个 GoNavi/updates,失败时保留安装包、脚本和日志,并补充跨平台路径与清理测试。
30 lines
776 B
Go
30 lines
776 B
Go
package app
|
|
|
|
import (
|
|
_ "embed"
|
|
"strings"
|
|
)
|
|
|
|
//go:embed windows_update.ps1
|
|
var windowsUpdatePowerShellScript string
|
|
|
|
// The updater writes these embedded scripts locally, so RemoteSigned runs them without disabling policy checks.
|
|
const windowsUpdatePowerShellExecutionPolicy = "RemoteSigned"
|
|
|
|
type windowsUpdateLaunchContext struct {
|
|
SourcePath string
|
|
TargetPath string
|
|
CurrentTargetPath string
|
|
UpdatesDir string
|
|
StagedDir string
|
|
LogPath string
|
|
MaintenanceEventName string
|
|
HandoffEventName string
|
|
PID int
|
|
}
|
|
|
|
func buildWindowsPowerShellScript() string {
|
|
normalized := strings.ReplaceAll(windowsUpdatePowerShellScript, "\r\n", "\n")
|
|
return strings.ReplaceAll(normalized, "\n", "\r\n")
|
|
}
|