feat: LAN auto-update launcher script (stage 3)
scripts/update.ps1: check manifest, stage+verify the new version, swap it in alongside the running one (versions\<ver> + current.txt pointer), then launch with CMBOT_DATA_DIR. Degrades to the local version on any failure; never overwrites the running version. Rollback = edit current.txt. Verified against a fake versioned layout: update, idempotent re-run, unreachable source, no source, corrupt download (marker missing), malformed manifest. Not yet wired into a real install layout (build.ps1 still ships flat onedir). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -229,8 +229,17 @@
|
||||
|
||||
1. **地基**:数据目录分离(第 5 节)。任何更新方案的前提。✅ 已实现。
|
||||
2. **只读通知**:启动时读取 `manifest.json` 比对版本,有新版仅提示并打开更新源目录(不自动安装)。✅ 已实现——`services/update_service.py`(`check_for_update` / 版本比较,纯逻辑可测)+ 主窗口顶部通知横幅,检查在后台线程进行(更新源不可达不阻塞启动),更新源路径由 `update_source` 配置。
|
||||
3. **自动安装**:实现启动器完整流程(下载 → 校验 → 原子切换 → 启动 → 回滚)。⛔ 未做。
|
||||
4. **强制更新与保留策略**:补全 `mandatory` / `min_supported` 与版本清理。⛔ 未做。
|
||||
3. **自动安装**:实现启动器完整流程(下载 → 校验 → 原子切换 → 启动 → 回滚)。🚧 启动器脚本 `scripts/update.ps1` 已实现并以假版本目录验证全流程(含源不可达、下载损坏、坏 manifest 等降级路径);尚未接入真实安装结构(`build.ps1` 仍产出扁平 onedir,无生成 `%LOCALAPPDATA%\CMBot\versions\<ver>\` 版本并排布局的安装步骤)。
|
||||
4. **强制更新与保留策略**:补全 `mandatory` / `min_supported` 与版本清理(保留最近 N 个)。⛔ 未做。
|
||||
|
||||
启动器(`scripts/update.ps1`)要点:
|
||||
|
||||
- 入口参数 `-InstallRoot`(默认脚本所在目录)、`-NoLaunch`(测试用,只更新不启动)。
|
||||
- 从 `<InstallRoot>\data\config\app_config.json` 读 `update_source`,与 stage ② 同源。
|
||||
- 下载到 `staging\<ver>.tmp` → 校验 `manifest.marker` 存在 → 重命名进 `versions\<ver>` → 原子写 `current.txt`(ascii 无 BOM)。
|
||||
- 启动 `versions\<current>\CMBot.exe` 并设 `CMBOT_DATA_DIR=<InstallRoot>\data`(接 stage ① 数据目录分离)。
|
||||
- 任何失败(源不可达 / robocopy 失败 / marker 缺失 / 坏 manifest)都降级启动本地现版本,绝不进入「无可启动版本」。
|
||||
- 旧版本目录保留,回滚 = 手改 `current.txt` 回旧版本号。
|
||||
|
||||
## 17. 暂不做
|
||||
|
||||
|
||||
Reference in New Issue
Block a user