fix(installer): stop the running app before updating, not just the worker
All checks were successful
Release / release (push) Successful in 34s
All checks were successful
Release / release (push) Successful in 34s
A running ClaudeDo.App.exe locks the install\app directory, so the extract step's Directory.Move failed with "Access to the path '...\app' is denied" during an update. StopWorkerStep now also terminates app processes scoped to the install dir (benefits uninstall too). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -7,25 +7,32 @@ namespace ClaudeDo.Installer.Steps;
|
|||||||
public sealed class StopWorkerStep : IInstallStep
|
public sealed class StopWorkerStep : IInstallStep
|
||||||
{
|
{
|
||||||
public const string LegacyTaskName = "ClaudeDoWorker";
|
public const string LegacyTaskName = "ClaudeDoWorker";
|
||||||
public const string ProcessName = "ClaudeDo.Worker";
|
|
||||||
|
// Both must be stopped before the install dir is touched: a running app/worker
|
||||||
|
// exe locks its directory, so Directory.Move during extraction would otherwise
|
||||||
|
// fail with "Access to the path '...\app' is denied".
|
||||||
|
private static readonly string[] ProcessNames = { "ClaudeDo.Worker", "ClaudeDo.App" };
|
||||||
|
|
||||||
public string Name => "Stop Worker";
|
public string Name => "Stop Worker";
|
||||||
|
|
||||||
public async Task<StepResult> ExecuteAsync(InstallContext ctx, IProgress<string> progress, CancellationToken ct)
|
public async Task<StepResult> ExecuteAsync(InstallContext ctx, IProgress<string> progress, CancellationToken ct)
|
||||||
{
|
{
|
||||||
progress.Report("Stopping worker process (if running)...");
|
progress.Report("Stopping ClaudeDo processes (if running)...");
|
||||||
var installDir = ctx.InstallDirectory;
|
var installDir = ctx.InstallDirectory;
|
||||||
foreach (var p in Process.GetProcessesByName(ProcessName))
|
foreach (var name in ProcessNames)
|
||||||
{
|
{
|
||||||
try
|
foreach (var p in Process.GetProcessesByName(name))
|
||||||
{
|
{
|
||||||
var path = p.MainModule?.FileName;
|
try
|
||||||
if (path is not null && !IsUnder(path, installDir)) continue;
|
{
|
||||||
p.Kill(entireProcessTree: true);
|
var path = p.MainModule?.FileName;
|
||||||
p.WaitForExit(10000);
|
if (path is not null && !IsUnder(path, installDir)) continue;
|
||||||
|
p.Kill(entireProcessTree: true);
|
||||||
|
p.WaitForExit(10000);
|
||||||
|
}
|
||||||
|
catch { /* process may have exited or be inaccessible */ }
|
||||||
|
finally { p.Dispose(); }
|
||||||
}
|
}
|
||||||
catch { /* process may have exited or be inaccessible */ }
|
|
||||||
finally { p.Dispose(); }
|
|
||||||
}
|
}
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
return StepResult.Ok();
|
return StepResult.Ok();
|
||||||
|
|||||||
Reference in New Issue
Block a user