Every update failed at "Could not replace the existing files": the app relaunches the installer via ShellExecute without a working directory, so it inherited the app's CWD - which the Start Menu shortcut sets to <InstallDir>\app. A process's current directory is locked by Windows, so the installer blocked its own `app` -> `app.bak` rename. Retries and reboots could not help. - installer moves its CWD to %TEMP% at startup, and both relaunch sites in the UI pass an explicit WorkingDirectory - cache the release zip in %TEMP%\ClaudeDo-download-cache and reuse it on a retry while its SHA-256 still matches, so a failed attempt no longer costs another full download; drop it after a successful install, delete a mismatching one, prune zips of other versions - roll back a half-done stash: a leftover app.bak was deleted as a stale stash on the next attempt, and that copy was the only one left - name the blocked path in the error message
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using ClaudeDo.Ui.Services;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace ClaudeDo.Ui.ViewModels.Modals;
|
|
|
|
public sealed partial class WorkerConnectionModalViewModel : ViewModelBase
|
|
{
|
|
private readonly WorkerLocator _workerLocator;
|
|
private readonly InstallerLocator _installerLocator;
|
|
|
|
public WorkerConnectionModalViewModel(WorkerLocator workerLocator, InstallerLocator installerLocator)
|
|
{
|
|
_workerLocator = workerLocator;
|
|
_installerLocator = installerLocator;
|
|
}
|
|
|
|
public Action? CloseAction { get; set; }
|
|
|
|
[RelayCommand] private void Close() => CloseAction?.Invoke();
|
|
|
|
[RelayCommand]
|
|
private void StartWorker()
|
|
{
|
|
var exe = _workerLocator.Find();
|
|
if (exe is null) return;
|
|
try { Process.Start(new ProcessStartInfo(exe) { UseShellExecute = true }); }
|
|
catch { /* nothing useful to show */ }
|
|
CloseAction?.Invoke();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void RerunInstaller()
|
|
{
|
|
var path = _installerLocator.Find();
|
|
if (path is null) return;
|
|
try
|
|
{
|
|
// See IslandsShellViewModel.UpdateNow: an inherited CWD inside the install dir
|
|
// makes the installer block its own app\ rename.
|
|
Process.Start(new ProcessStartInfo(path)
|
|
{
|
|
UseShellExecute = true,
|
|
WorkingDirectory = Path.GetTempPath(),
|
|
});
|
|
Environment.Exit(0);
|
|
}
|
|
catch { /* nothing useful to show */ }
|
|
}
|
|
}
|