Skip to content

Commit 7d6d195

Browse files
JusterZhuclaude
andcommitted
fix: Discover before server call, preserve caller precedence
- Move Discover BEFORE HttpDownloadSource construction so the server call sees real manifest values, not placeholder defaults. - Discover only fills empty context fields — caller-provided values take precedence over manifest (matches old ?? behaviour). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3574698 commit 7d6d195

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/c#/GeneralUpdate.Core/Configuration/AppMetadataDiscoverer.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ public static void Discover(UpdateContext context)
2525

2626
if (manifest == null) return;
2727

28-
if (!string.IsNullOrWhiteSpace(manifest.MainAppName))
28+
// Only fill empty fields — caller-provided values take precedence.
29+
if (string.IsNullOrWhiteSpace(context.MainAppName) && !string.IsNullOrWhiteSpace(manifest.MainAppName))
2930
context.MainAppName = manifest.MainAppName;
30-
if (!string.IsNullOrWhiteSpace(manifest.UpdateAppName))
31+
if (string.IsNullOrWhiteSpace(context.UpdateAppName) && !string.IsNullOrWhiteSpace(manifest.UpdateAppName))
3132
context.UpdateAppName = manifest.UpdateAppName;
32-
if (!string.IsNullOrWhiteSpace(manifest.ClientVersion))
33+
if (string.IsNullOrWhiteSpace(context.ClientVersion) && !string.IsNullOrWhiteSpace(manifest.ClientVersion))
3334
context.ClientVersion = manifest.ClientVersion;
34-
if (!string.IsNullOrWhiteSpace(manifest.UpgradeClientVersion))
35+
if (string.IsNullOrWhiteSpace(context.UpgradeClientVersion) && !string.IsNullOrWhiteSpace(manifest.UpgradeClientVersion))
3536
context.UpgradeClientVersion = manifest.UpgradeClientVersion;
36-
if (!string.IsNullOrWhiteSpace(manifest.ProductId))
37+
if (string.IsNullOrWhiteSpace(context.ProductId) && !string.IsNullOrWhiteSpace(manifest.ProductId))
3738
context.ProductId = manifest.ProductId;
38-
if (!string.IsNullOrWhiteSpace(manifest.UpdatePath))
39+
if (string.IsNullOrWhiteSpace(context.UpdatePath) && !string.IsNullOrWhiteSpace(manifest.UpdatePath))
3940
context.UpdatePath = manifest.UpdatePath;
40-
if (!string.IsNullOrWhiteSpace(manifest.AppType)
41+
if (context.AppType == null && !string.IsNullOrWhiteSpace(manifest.AppType)
4142
&& Enum.TryParse<AppType>(manifest.AppType, out var at))
4243
context.AppType = at;
4344
}

src/c#/GeneralUpdate.Core/Strategy/ClientStrategy.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@ private async Task ExecuteStandardWorkflowAsync()
398398
GeneralTracer.Info(
399399
$"ClientStrategy: validating client={_configInfo!.ClientVersion}, upgrade={_configInfo.UpgradeClientVersion}");
400400

401+
// Discover identity metadata from the manifest in InstallPath BEFORE
402+
// constructing HttpDownloadSource so the server call sees real values.
403+
// UpdateStrategy writes versions back to InstallPath after each update;
404+
// using the parameterless Load() would read from BaseDirectory instead
405+
// and could pick up a stale manifest when InstallPath is customized.
406+
// Only fills empty fields — caller-provided values take precedence.
407+
AppMetadataDiscoverer.Discover(_configInfo!);
408+
401409
// Use injected DownloadSource (Hub/HTTP), or default to HttpDownloadSource
402410
var downloadSource = DownloadSource ?? new Download.Sources.HttpDownloadSource(
403411
_configInfo.UpdateUrl,
@@ -412,12 +420,6 @@ private async Task ExecuteStandardWorkflowAsync()
412420
// Call server validation — returns assets from the two Validate calls
413421
var sourceResult = await downloadSource.ListAsync().ConfigureAwait(false);
414422

415-
// Discover identity metadata from the manifest in InstallPath.
416-
// UpdateStrategy writes versions back to InstallPath after each update;
417-
// using the parameterless Load() would read from BaseDirectory instead
418-
// and could pick up a stale manifest when InstallPath is customized.
419-
// Caller's explicit value takes precedence; manifest is a fallback.
420-
AppMetadataDiscoverer.Discover(_configInfo!);
421423
var localClientVersion = _configInfo!.ClientVersion;
422424
var localUpgradeVersion = _configInfo.UpgradeClientVersion ?? localClientVersion;
423425

0 commit comments

Comments
 (0)