Files
MyGoNavi/internal/app/windows_update_script.go
liuqiufeng 9c42cfeec4 fix(update): 统一更新缓存与成功清理目录
统一 macOS、Windows 和 Linux 更新包到用户缓存目录,失败时回退系统临时目录。成功更新后清理整个 GoNavi/updates,失败时保留安装包、脚本和日志,并补充跨平台路径与清理测试。
2026-07-28 22:11:33 +08:00

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