Repository navigation
PR: Gap fill 1 - Missing types (DiffMode, BlackListConfig, DownloadAsset, PacketDTO, MacStrategy) - #335
Merged
Conversation
…g, DownloadAsset, PacketDTO, MacStrategy - DiffMode enum (Serial/Parallel) - HubConfig (Url, ReconnectDelay, MaxReconnectAttempts) - BlackListConfig record (BlackFiles/BlackFormats/SkipDirectorys + Empty) - DownloadAsset + DownloadPlan records (with cross-version fields) - IDownloadSource + IDownloadPipeline interfaces - PacketDTO + VersionRequest + VersionResponse server contracts - DefaultDownloadPipeline (SHA256 verify) - DownloadProgressReporter (IProgress to event bridge) - OssDownloadExecutor (OSS HTTP download) - MacStrategy (macOS update strategy) Closes #334
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fills in several missing Core types identified by the plan-vs-implementation audit (issue #334), primarily around download abstractions/models and platform strategy support.
Changes:
- Adds new configuration types (DiffMode, HubConfig, BlackListConfig).
- Introduces a download model/abstraction surface (DownloadAsset/DownloadPlan, IDownloadSource/IDownloadPipeline, PacketDTO contracts) plus basic implementations (SHA256 pipeline, OSS executor, progress reporter).
- Adds a new macOS strategy implementation (MacStrategy).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/c#/GeneralUpdate.Core/Strategy/MacStrategy.cs | Adds a macOS strategy class. |
| src/c#/GeneralUpdate.Core/Download/Progress/DownloadProgressReporter.cs | Adds an adapter from IProgress<DownloadProgress> to callbacks. |
| src/c#/GeneralUpdate.Core/Download/Pipeline/DefaultDownloadPipeline.cs | Adds a post-download SHA256 verification pipeline. |
| src/c#/GeneralUpdate.Core/Download/Models/DownloadAsset.cs | Adds download asset/plan records. |
| src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs | Adds a simple OSS (signed URL) HTTP download executor. |
| src/c#/GeneralUpdate.Core/Download/Abstractions/PacketDTO.cs | Adds packet/version request/response DTOs for server contracts. |
| src/c#/GeneralUpdate.Core/Download/Abstractions/IDownloadSource.cs | Adds download source + post-processing pipeline interfaces. |
| src/c#/GeneralUpdate.Core/Configuration/HubConfig.cs | Adds HubConfig settings container. |
| src/c#/GeneralUpdate.Core/Configuration/DiffMode.cs | Adds DiffMode enum (Serial/Parallel). |
| src/c#/GeneralUpdate.Core/Configuration/BlackListConfig.cs | Adds blacklist config record with Empty/HasRules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| public override void Execute() | ||
| { | ||
| GeneralTracer.Info("MacStrategy: executing macOS update"); |
Comment on lines
+19
to
+24
| var mainApp = Path.Combine(_configinfo.InstallPath, _configinfo.MainAppName); | ||
| if (File.Exists(mainApp)) | ||
| { | ||
| GeneralTracer.Info($"MacStrategy: starting {mainApp}"); | ||
| Process.Start(mainApp); | ||
| } |
Comment on lines
+27
to
+28
| _onCompleted?.Invoke(null!); // result will be set by caller | ||
| } |
| private static async Task<string> ComputeSha256Async(string path, CancellationToken token) | ||
| { | ||
| using var sha = SHA256.Create(); | ||
| using var fs = new FileStream(path, FileMode.Open, FileAccess.Read); |
Comment on lines
+35
to
+45
| while ((read = await stream.ReadAsync(buffer, 0, buffer.Length, token)) > 0) | ||
| { | ||
| await fs.WriteAsync(buffer, 0, read, token); | ||
| downloaded += read; | ||
| var pct = total > 0 ? (double)downloaded / total * 100 : -1; | ||
| progress?.Report(new DownloadProgress( | ||
| Path.GetFileName(destPath), downloaded, total > 0 ? total : null, pct, DownloadStatus.Downloading)); | ||
| } | ||
| sw.Stop(); | ||
| progress?.Report(new DownloadProgress(Path.GetFileName(destPath), downloaded, total > 0 ? total : null, 100, DownloadStatus.Completed)); | ||
| return new DownloadResult(url, destPath, downloaded, sw.Elapsed, 0, true, null); |
Comment on lines
+27
to
+37
| using var response = await _client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token); | ||
| response.EnsureSuccessStatusCode(); | ||
| var total = response.Content.Headers.ContentLength ?? -1; | ||
| using var fs = new FileStream(destPath, FileMode.Create); | ||
| using var stream = await response.Content.ReadAsStreamAsync(); | ||
| var buffer = new byte[8192]; | ||
| long downloaded = 0; | ||
| int read; | ||
| while ((read = await stream.ReadAsync(buffer, 0, buffer.Length, token)) > 0) | ||
| { | ||
| await fs.WriteAsync(buffer, 0, read, token); |
Comment on lines
+9
to
+22
| public record PacketDTO | ||
| { | ||
| public string? Name { get; set; } | ||
| public string? Hash { get; set; } | ||
| public DateTime? ReleaseDate { get; set; } | ||
| public string? Url { get; set; } | ||
| public string? Version { get; set; } | ||
| public int? AppType { get; set; } | ||
| public int? Platform { get; set; } | ||
| public string? ProductId { get; set; } | ||
| public bool? IsForcibly { get; set; } | ||
| public bool? IsFreeze { get; set; } | ||
| public string? Format { get; set; } | ||
| public long Size { get; set; } |
Comment on lines
+21
to
+27
| public string? Format { get; set; } | ||
| public long Size { get; set; } | ||
| public string? FromVersion { get; set; } | ||
| public bool? IsCrossVersion { get; set; } | ||
| public string? MinClientVersion { get; set; } | ||
| public string? SourceArchiveHash { get; set; } | ||
| public string? TargetArchiveHash { get; set; } |
Comment on lines
+3
to
+4
| using System.Threading; | ||
| using System.Threading.Tasks; |
…porter, etc. - PacketDTO: nullable Size, remove unused usings - DownloadProgressReporter: remove null!, safer callback design - DefaultDownloadPipeline: FileShare.Read - OssDownloadExecutor: throttling + ConfigureAwait + create dest dir - MacStrategy: BuildPipeline + error handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #334. 10 new files — filling types gap from plan-vs-implementation audit.
Files
Build
✅ 0 errors