fix(installer): fall back to Config on detection timeout when install.json exists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mika Kuns
2026-04-15 10:10:02 +02:00
parent 01c29bb6f6
commit 5e432a4a27

View File

@@ -1,4 +1,3 @@
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Windows;
@@ -29,7 +28,13 @@ public partial class App : Application
// Default install dir for detection — on upgrade we stay where we were.
var detector = _services.GetRequiredService<InstallModeDetector>();
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
// Read manifest up front so we can fall back to Config if the API times out
// on an existing install. If the API is slow, we do NOT want to drop an
// already-installed user into FreshInstall — that would risk overwriting them.
var existingManifest = InstallManifestStore.TryRead(context.InstallDirectory);
DetectedState state;
try
{
@@ -37,7 +42,9 @@ public partial class App : Application
}
catch (OperationCanceledException)
{
state = new DetectedState(InstallerMode.FreshInstall, null, null, null);
state = existingManifest is not null
? new DetectedState(InstallerMode.Config, existingManifest, null, null)
: new DetectedState(InstallerMode.FreshInstall, null, null, null);
}
context.Mode = state.Mode;