Skip to content

Commit 7c3d702

Browse files
authored
fix: address Copilot review suggestions across all merged PRs (#418)
- OSSUpdateStrategy: make DownloadVersionConfig truly async - DefaultDownloadOrchestrator: pass full DownloadAsset in failedDetails - DownloadResult.LocalPath: change from string? to string - Executors failure paths: return destPath instead of null for LocalPath
1 parent 656468c commit 7c3d702

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/c#/GeneralUpdate.Core/Download/Executors/HttpDownloadExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public async Task<DownloadResult> ExecuteAsync(
7979
catch (Exception ex) when (ex is not OperationCanceledException)
8080
{
8181
sw.Stop();
82-
return new DownloadResult(asset, null, existingBytes, sw.Elapsed, retries, false, ex.Message);
82+
return new DownloadResult(asset, destPath, existingBytes, sw.Elapsed, retries, false, ex.Message);
8383
}
8484
}
8585

src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task<DownloadResult> ExecuteAsync(
4242
catch (Exception ex) when (ex is not OperationCanceledException)
4343
{
4444
sw.Stop();
45-
return new DownloadResult(asset, null, 0, sw.Elapsed, 0, false, ex.Message);
45+
return new DownloadResult(asset, destPath, 0, sw.Elapsed, 0, false, ex.Message);
4646
}
4747
}
4848
}

src/c#/GeneralUpdate.Core/Download/Models/DownloadProgress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DownloadStatus Status
1616

1717
public record DownloadResult(
1818
DownloadAsset Asset,
19-
string? LocalPath,
19+
string LocalPath,
2020
long DownloadedBytes,
2121
TimeSpan Duration,
2222
int RetryCount,

src/c#/GeneralUpdate.Core/Download/Orchestrators/DefaultDownloadOrchestrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public async Task<DownloadReport> ExecuteAsync(
122122

123123
// Dispatch all-completed event ONCE after all assets finish (only failed results)
124124
var failedDetails = results.Where(r => !r.Success)
125-
.Select(r => ((object)r.Asset.Url, r.ErrorMessage ?? "failed")).ToList();
125+
.Select(r => ((object)r.Asset, r.ErrorMessage ?? "failed")).ToList();
126126
DownloadProgressReporter.DispatchAllCompleted(
127127
this,
128128
results.All(r => r.Success),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private async Task ExecuteClientAsync()
7474

7575
if (!string.IsNullOrEmpty(_configInfo.UpdateUrl))
7676
{
77-
DownloadVersionConfig(_configInfo.UpdateUrl, versionsFilePath);
77+
await DownloadVersionConfig(_configInfo.UpdateUrl, versionsFilePath).ConfigureAwait(false);
7878
}
7979

8080
if (!File.Exists(versionsFilePath))
@@ -210,15 +210,15 @@ public void StartApp()
210210

211211
#region Helpers
212212

213-
private static void DownloadVersionConfig(string url, string path)
213+
private static async Task DownloadVersionConfig(string url, string path)
214214
{
215215
if (File.Exists(path))
216216
{
217217
File.SetAttributes(path, FileAttributes.Normal);
218218
File.Delete(path);
219219
}
220220
using var httpClient = new HttpClient();
221-
var bytes = httpClient.GetByteArrayAsync(url).GetAwaiter().GetResult();
221+
var bytes = await httpClient.GetByteArrayAsync(url).ConfigureAwait(false);
222222
File.WriteAllBytes(path, bytes);
223223
}
224224

0 commit comments

Comments
 (0)