跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

UpdateRecovery.cs

34 行 · 1.4 KB历史下载
1namespace Cage.Windows;
2
3internal static class UpdateRecovery
4{
5 public static string BackendPath(string backup) => Path.Combine(backup, "resources", "cage.exe");
6
7 // The installed candidate may be unable to start. Use the existing backup's
8 // verified controller to check the shared profile and stop any new process.
9 public static async Task PrepareRollback(string backup, CancellationToken cancellation = default)
10 {
11 var (exit, result) = await Backend.JsonAt(BackendPath(backup), ["prepare-update", "--json", "--stop"], cancellation);
12 if (exit != 0 || result.Text("status") != "prepared")
13 throw new IOException("旧版后台无法确认环境已停止,原应用备份已保留");
14 }
15
16 public static void CleanupDirectory(string? path)
17 {
18 if (path == null) return;
19 try { Directory.Delete(path, true); }
20 catch (IOException) { }
21 catch (UnauthorizedAccessException) { }
22 }
23
24 // This only runs after workbench acknowledgement. Cleanup failures leave
25 // files for later removal and cannot change the installation result.
26 public static void CleanupAfterSuccess(string backup, string download, string marker)
27 {
28 CleanupDirectory(backup);
29 CleanupDirectory(download);
30 try { File.Delete(marker); }
31 catch (IOException) { }
32 catch (UnauthorizedAccessException) { }
33 }
34}