From 3b6e43fae1c20f288c8f792987593cc8b5a181ff Mon Sep 17 00:00:00 2001 From: codex Date: Fri, 31 Jul 2026 15:44:44 +0300 Subject: [PATCH] fix: allow new pilot run after completed rollback --- Launcher.Next.App/PilotCli.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Launcher.Next.App/PilotCli.cs b/Launcher.Next.App/PilotCli.cs index 49b9af6..b977ff7 100644 --- a/Launcher.Next.App/PilotCli.cs +++ b/Launcher.Next.App/PilotCli.cs @@ -32,7 +32,7 @@ internal static class PilotCli Directory.CreateDirectory(Path.Combine(root, "catalog")); await File.WriteAllTextAsync(Path.Combine(root, "catalog", "P_Rec_Annot.manifest.json"), JsonSerializer.Serialize(manifest)); if (!File.Exists(@"C:\Program Files\Autodesk\AutoCAD 2026\acad.exe")) return Fail(DiscoveryFailed, "PLANT3D_2026_NOT_FOUND"); - if (command == "run" && File.Exists(SessionPath(root))) return await HandleExistingSession(root); + if (command == "run" && File.Exists(SessionPath(root)) && await HasActiveSession(root)) return await HandleExistingSession(root); var service = CreateService(); var product = new ProductInstallation(@"C:\Program Files\Autodesk\AutoCAD 2026\acad.exe", "2026", "x64", []); var request = new PilotPreparationRequest(config, product, manifest!, manifestHash!, options.PackageSource!, root, Path.Combine(root, "startup", "prepare-only.scr")); @@ -96,6 +96,11 @@ internal static class PilotCli var state = document.RootElement.GetProperty("State").GetString(); return state == "RolledBack" ? Success : Fail(SessionConflict, "PILOT_SESSION_ALREADY_ACTIVE"); } + private static async Task HasActiveSession(string root) + { + using var document = JsonDocument.Parse(await File.ReadAllTextAsync(SessionPath(root))); + return document.RootElement.GetProperty("State").GetString() != "RolledBack"; + } private static async Task IsRolledBack(string root) { if (!File.Exists(SessionPath(root))) return false;