diff --git a/src/c#/GeneralUpdate.Core/Download/Executors/HttpDownloadExecutor.cs b/src/c#/GeneralUpdate.Core/Download/Executors/HttpDownloadExecutor.cs index 7293061c..fb0e7d62 100644 --- a/src/c#/GeneralUpdate.Core/Download/Executors/HttpDownloadExecutor.cs +++ b/src/c#/GeneralUpdate.Core/Download/Executors/HttpDownloadExecutor.cs @@ -79,7 +79,7 @@ public async Task ExecuteAsync( catch (Exception ex) when (ex is not OperationCanceledException) { sw.Stop(); - return new DownloadResult(asset, null, existingBytes, sw.Elapsed, retries, false, ex.Message); + return new DownloadResult(asset, destPath, existingBytes, sw.Elapsed, retries, false, ex.Message); } } diff --git a/src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs b/src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs index d145275e..62d9aef4 100644 --- a/src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs +++ b/src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs @@ -42,7 +42,7 @@ public async Task ExecuteAsync( catch (Exception ex) when (ex is not OperationCanceledException) { sw.Stop(); - return new DownloadResult(asset, null, 0, sw.Elapsed, 0, false, ex.Message); + return new DownloadResult(asset, destPath, 0, sw.Elapsed, 0, false, ex.Message); } } } diff --git a/src/c#/GeneralUpdate.Core/Download/Models/DownloadProgress.cs b/src/c#/GeneralUpdate.Core/Download/Models/DownloadProgress.cs index 7e838819..26981728 100644 --- a/src/c#/GeneralUpdate.Core/Download/Models/DownloadProgress.cs +++ b/src/c#/GeneralUpdate.Core/Download/Models/DownloadProgress.cs @@ -16,7 +16,7 @@ DownloadStatus Status public record DownloadResult( DownloadAsset Asset, - string? LocalPath, + string LocalPath, long DownloadedBytes, TimeSpan Duration, int RetryCount, diff --git a/src/c#/GeneralUpdate.Core/Download/Orchestrators/DefaultDownloadOrchestrator.cs b/src/c#/GeneralUpdate.Core/Download/Orchestrators/DefaultDownloadOrchestrator.cs index 35423f59..48b647a3 100644 --- a/src/c#/GeneralUpdate.Core/Download/Orchestrators/DefaultDownloadOrchestrator.cs +++ b/src/c#/GeneralUpdate.Core/Download/Orchestrators/DefaultDownloadOrchestrator.cs @@ -122,7 +122,7 @@ public async Task ExecuteAsync( // Dispatch all-completed event ONCE after all assets finish (only failed results) var failedDetails = results.Where(r => !r.Success) - .Select(r => ((object)r.Asset.Url, r.ErrorMessage ?? "failed")).ToList(); + .Select(r => ((object)r.Asset, r.ErrorMessage ?? "failed")).ToList(); DownloadProgressReporter.DispatchAllCompleted( this, results.All(r => r.Success), diff --git a/src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs b/src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs index e7233392..51a2ff51 100644 --- a/src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs @@ -74,7 +74,7 @@ private async Task ExecuteClientAsync() if (!string.IsNullOrEmpty(_configInfo.UpdateUrl)) { - DownloadVersionConfig(_configInfo.UpdateUrl, versionsFilePath); + await DownloadVersionConfig(_configInfo.UpdateUrl, versionsFilePath).ConfigureAwait(false); } if (!File.Exists(versionsFilePath)) @@ -210,7 +210,7 @@ public void StartApp() #region Helpers - private static void DownloadVersionConfig(string url, string path) + private static async Task DownloadVersionConfig(string url, string path) { if (File.Exists(path)) { @@ -218,7 +218,7 @@ private static void DownloadVersionConfig(string url, string path) File.Delete(path); } using var httpClient = new HttpClient(); - var bytes = httpClient.GetByteArrayAsync(url).GetAwaiter().GetResult(); + var bytes = await httpClient.GetByteArrayAsync(url).ConfigureAwait(false); File.WriteAllBytes(path, bytes); }