@@ -9,42 +9,37 @@ namespace GeneralUpdate.Core.Configuration;
99public static class AppMetadataDiscoverer
1010{
1111 /// <summary>
12- /// Discover and fill every null-or-empty identity field in <paramref name="seed"/>.
12+ /// Discover and fill every null-or-empty identity field in <paramref name="context"/>
13+ /// from <c>generalupdate.manifest.json</c>. Called by <see cref="ClientStrategy"/>
14+ /// during <c>ExecuteStandardWorkflowAsync</c> so that manifest discovery is owned
15+ /// by the strategy rather than the bootstrap.
1316 /// </summary>
14- public static UpdateRequest Discover ( UpdateRequest seed )
17+ public static void Discover ( UpdateContext context )
1518 {
16- if ( seed == null )
17- throw new System . ArgumentNullException ( nameof ( seed ) ) ;
19+ if ( context == null )
20+ throw new System . ArgumentNullException ( nameof ( context ) ) ;
1821
19- var manifest = ManifestInfo . Load ( ) ;
22+ var installPath = context . InstallPath ;
23+ var manifestPath = System . IO . Path . Combine ( installPath , ManifestInfo . FileName ) ;
24+ var manifest = ManifestInfo . Load ( manifestPath ) ;
2025
21- // Identity fields — manifest overrides defaults, not just nulls.
22- // (UpdateConfiguration pre-fills UpdateAppName with "Update.exe", so simple
23- // null-coalescing would never pick up the manifest value.)
24- if ( manifest != null )
25- {
26- if ( ! string . IsNullOrWhiteSpace ( manifest . MainAppName ) )
27- seed . MainAppName = manifest . MainAppName ;
28- if ( ! string . IsNullOrWhiteSpace ( manifest . UpdateAppName ) )
29- seed . UpdateAppName = manifest . UpdateAppName ;
30- if ( ! string . IsNullOrWhiteSpace ( manifest . ClientVersion ) )
31- seed . ClientVersion = manifest . ClientVersion ;
32- if ( ! string . IsNullOrWhiteSpace ( manifest . UpgradeClientVersion ) )
33- seed . UpgradeClientVersion = manifest . UpgradeClientVersion ;
34- if ( ! string . IsNullOrWhiteSpace ( manifest . ProductId ) )
35- seed . ProductId = manifest . ProductId ;
36- if ( ! string . IsNullOrWhiteSpace ( manifest . UpdatePath ) )
37- seed . UpdatePath = manifest . UpdatePath ;
38- if ( ! string . IsNullOrWhiteSpace ( manifest . AppType )
39- && Enum . TryParse < AppType > ( manifest . AppType , out var at ) )
40- seed . AppType = at ;
41- }
26+ if ( manifest == null ) return ;
4227
43- // Hard-coded fallbacks only when neither seed nor manifest provided a value.
44- seed . MainAppName ??= "Client" ;
45- seed . UpdateAppName ??= "Update.exe" ;
46- seed . InstallPath ??= AppDomain . CurrentDomain . BaseDirectory ;
47-
48- return seed ;
28+ // Only fill empty fields — caller-provided values take precedence.
29+ if ( string . IsNullOrWhiteSpace ( context . MainAppName ) && ! string . IsNullOrWhiteSpace ( manifest . MainAppName ) )
30+ context . MainAppName = manifest . MainAppName ;
31+ if ( string . IsNullOrWhiteSpace ( context . UpdateAppName ) && ! string . IsNullOrWhiteSpace ( manifest . UpdateAppName ) )
32+ context . UpdateAppName = manifest . UpdateAppName ;
33+ if ( string . IsNullOrWhiteSpace ( context . ClientVersion ) && ! string . IsNullOrWhiteSpace ( manifest . ClientVersion ) )
34+ context . ClientVersion = manifest . ClientVersion ;
35+ if ( string . IsNullOrWhiteSpace ( context . UpgradeClientVersion ) && ! string . IsNullOrWhiteSpace ( manifest . UpgradeClientVersion ) )
36+ context . UpgradeClientVersion = manifest . UpgradeClientVersion ;
37+ if ( string . IsNullOrWhiteSpace ( context . ProductId ) && ! string . IsNullOrWhiteSpace ( manifest . ProductId ) )
38+ context . ProductId = manifest . ProductId ;
39+ if ( string . IsNullOrWhiteSpace ( context . UpdatePath ) && ! string . IsNullOrWhiteSpace ( manifest . UpdatePath ) )
40+ context . UpdatePath = manifest . UpdatePath ;
41+ if ( context . AppType == null && ! string . IsNullOrWhiteSpace ( manifest . AppType )
42+ && Enum . TryParse < AppType > ( manifest . AppType , out var at ) )
43+ context . AppType = at ;
4944 }
5045}
0 commit comments