Skip to content

Commit 1e95161

Browse files
committed
fix: Copilot review — Hub startup, macOS detection, binary compat, cleanup
- HubDownloadSource: call StartAsync() on injection, dispose in finally - GetPlatform(): add OSPlatform.OSX -> PlatformType.MacOS in both locations - VersionService.Validate: keep int overload for backward binary compat - ClientUpdateStrategy: DownloadSource resolved from extension registry + comment fix - SharedMemoryProvider: catch broader exceptions on Linux (non-Windows MMF) - CI: document ConfiginfoBuilderTests exclusion rationale
1 parent eb1bd58 commit 1e95161

6 files changed

Lines changed: 42 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929

3030
- name: Test (Windows)
3131
if: runner.os == 'Windows'
32+
# ConfiginfoBuilderTests excluded: pre-existing regression (tracked in issue tracker),
33+
# does not block CI signal for the changes in this PR.
3234
run: dotnet test ./src/c#/GeneralUpdate.slnx -c Release --no-build --filter "FullyQualifiedName!~ConfiginfoBuilderTests"
3335

3436
- name: Test (Ubuntu - cross-platform)

src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,25 @@ private async Task<GeneralUpdateBootstrap> LaunchWithStrategy(IStrategy roleStra
9494
{
9595
clientStrat.Hooks = hooks;
9696
clientStrat.Reporter = reporter;
97-
// Inject SignalR Hub download source if configured
98-
var hubConfig = GetOption(UpdateOptions.Hub);
99-
if (hubConfig != null && !string.IsNullOrEmpty(hubConfig.Url))
97+
// Resolve DownloadSource from extension registry (Hub, custom, etc.)
98+
var resolvedSource = ResolveExtension<Download.Abstractions.IDownloadSource>();
99+
100+
// Inject SignalR Hub download source if configured (not available in AOT)
101+
#if !AOT
102+
if (resolvedSource == null)
100103
{
101-
clientStrat.DownloadSource = new Download.Sources.HubDownloadSource(
102-
hubConfig.Url, GetOption(UpdateOptions.Token), GetOption(UpdateOptions.AppSecretKey));
103-
GeneralTracer.Info("GeneralUpdateBootstrap: HubDownloadSource injected from HubConfig.");
104+
var hubConfig = GetOption(UpdateOptions.Hub);
105+
if (hubConfig != null && !string.IsNullOrEmpty(hubConfig.Url))
106+
{
107+
var hubSource = new Download.Sources.HubDownloadSource(
108+
hubConfig.Url, GetOption(UpdateOptions.Token), GetOption(UpdateOptions.AppSecretKey));
109+
await hubSource.StartAsync().ConfigureAwait(false);
110+
resolvedSource = hubSource;
111+
GeneralTracer.Info("GeneralUpdateBootstrap: HubDownloadSource started from HubConfig.");
112+
}
104113
}
114+
#endif
115+
clientStrat.DownloadSource = resolvedSource;
105116
if (_updatePrecheck != null)
106117
clientStrat.UseUpdatePrecheck(_updatePrecheck);
107118
foreach (var opt in _customOptions)
@@ -129,6 +140,9 @@ private async Task<GeneralUpdateBootstrap> LaunchWithStrategy(IStrategy roleStra
129140
}
130141
finally
131142
{
143+
// Dispose HubDownloadSource if it was started
144+
if (roleStrategy is ClientUpdateStrategy cs && cs.DownloadSource is IDisposable d)
145+
d.Dispose();
132146
_cts?.Dispose();
133147
_cts = null;
134148
}

src/c#/GeneralUpdate.Core/Ipc/IProcessInfoProvider.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ public Task SendAsync(ProcessInfo info, CancellationToken token = default)
139139
{
140140
return Task.FromResult<ProcessInfo?>(null);
141141
}
142+
catch (DirectoryNotFoundException)
143+
{
144+
return Task.FromResult<ProcessInfo?>(null);
145+
}
146+
catch (Exception ex) when (ex is not OutOfMemoryException)
147+
{
148+
// Platform-specific failures (e.g. Linux /dev/shm not mounted)
149+
GeneralTracer.Warn($"SharedMemoryProvider: receive failed: {ex.Message}");
150+
return Task.FromResult<ProcessInfo?>(null);
151+
}
142152
}
143153
}
144154

src/c#/GeneralUpdate.Core/Network/VersionService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static Task Report(string url, int recordId, int status, int? type,
5454
return new VersionService(a).ReportAsync(url, recordId, status, type, ct);
5555
}
5656

57+
// Strongly-typed overload (preferred)
5758
public static Task<VersionRespDTO> Validate(string url, string version,
5859
AppType appType, string appKey, PlatformType platform, string productId,
5960
string scheme = null, string token = null, CancellationToken ct = default)
@@ -62,6 +63,12 @@ public static Task<VersionRespDTO> Validate(string url, string version,
6263
return new VersionService(a).ValidateAsync(url, version, (int)appType, (int)platform, productId, ct);
6364
}
6465

66+
// Backward-compatible int overload (binary compat for existing callers)
67+
public static Task<VersionRespDTO> Validate(string url, string version,
68+
int appType, string appKey, int platform, string productId,
69+
string scheme = null, string token = null, CancellationToken ct = default)
70+
=> Validate(url, version, (AppType)appType, appKey, (PlatformType)platform, productId, scheme, token, ct);
71+
6572
private async Task ReportAsync(string url, int recordId, int status, int? type, CancellationToken t = default)
6673
{
6774
var p = new Dictionary<string, object> { ["RecordId"] = recordId, ["Status"] = status, ["Type"] = type };

src/c#/GeneralUpdate.Core/Silent/SilentPollOrchestrator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ private static PlatformType GetPlatform()
199199
{
200200
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return PlatformType.Windows;
201201
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return PlatformType.Linux;
202+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) return PlatformType.MacOS;
202203
return PlatformType.Unknown;
203204
}
204205

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ClientUpdateStrategy : IStrategy
3838
public Hooks.IUpdateHooks Hooks { get; set; } = new Hooks.NoOpUpdateHooks();
3939
/// <summary>Update status reporter injected by the bootstrap.</summary>
4040
public Download.Reporting.IUpdateReporter Reporter { get; set; } = new Download.Reporting.NoOpUpdateReporter();
41-
/// <summary>Download source (e.g., HTTP, SignalR Hub). Override via <c>.DownloadSource&lt;T&gt;()</c>.</summary>
41+
/// <summary>Download source (e.g., HTTP, SignalR Hub). Injected by bootstrap via HubConfig or extension registry (<c>.DownloadSource&lt;T&gt;()</c>).</summary>
4242
public Download.Abstractions.IDownloadSource? DownloadSource { get; set; }
4343

4444
public ClientUpdateStrategy(Download.Abstractions.IDownloadOrchestrator? orchestrator = null) { _orchestrator = orchestrator; }
@@ -276,6 +276,7 @@ private static PlatformType GetPlatform()
276276
{
277277
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return PlatformType.Windows;
278278
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return PlatformType.Linux;
279+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) return PlatformType.MacOS;
279280
return PlatformType.Unknown;
280281
}
281282

0 commit comments

Comments
 (0)