diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs index 32c49505..ed3abbd4 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs @@ -247,8 +247,8 @@ private void ApplyRuntimeOptions() { _configInfo.Encoding = GetOption(UpdateOption.Encoding) ?? Encoding.Default; _configInfo.Format = GetOption(UpdateOption.Format) ?? Format.ZIP; - var downloadTimeoutOption = GetOption(UpdateOption.DownloadTimeOut); - _configInfo.DownloadTimeOut = downloadTimeoutOption ?? 60; + var downloadTimeOut = GetOption(UpdateOption.DownloadTimeOut); + _configInfo.DownloadTimeOut = downloadTimeOut == 0 ? 60 : downloadTimeOut; _configInfo.DriveEnabled = GetOption(UpdateOption.Drive) ?? false; _configInfo.PatchEnabled = GetOption(UpdateOption.Patch) ?? true; } diff --git a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs index 5bb961db..ad24aad1 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs @@ -21,82 +21,79 @@ public class LinuxStrategy : AbstractStrategy public override void Create(GlobalConfigInfo parameter) => _configinfo = parameter; - public override void Execute() + public override async Task ExecuteAsync() { - Task.Run(async () => + try { - try + var status = ReportType.None; + var patchPath = StorageManager.GetTempDirectory(Patchs); + foreach (var version in _configinfo.UpdateVersions) { - var status = ReportType.None; - var patchPath = StorageManager.GetTempDirectory(Patchs); - foreach (var version in _configinfo.UpdateVersions) + try { - try - { - var context = new PipelineContext(); - //Common - context.Add("ZipFilePath", - Path.Combine(_configinfo.TempPath, $"{version.Name}{_configinfo.Format}")); - //Hash middleware - context.Add("Hash", version.Hash); - //Zip middleware - context.Add("Format", _configinfo.Format); - context.Add("Name", version.Name); - context.Add("Encoding", _configinfo.Encoding); - //Patch middleware - context.Add("SourcePath", _configinfo.InstallPath); - context.Add("PatchPath", patchPath); - context.Add("PatchEnabled", _configinfo.PatchEnabled); - //Driver middleware - if (_configinfo.DriveEnabled == true) - { - context.Add("DriverOutPut", StorageManager.GetTempDirectory("DriverOutPut")); - context.Add("FieldMappings", _configinfo.FieldMappings); - } - - var pipelineBuilder = new PipelineBuilder(context) - .UseMiddlewareIf(_configinfo.PatchEnabled) - .UseMiddleware() - .UseMiddleware() - .UseMiddlewareIf(_configinfo.DriveEnabled); - await pipelineBuilder.Build(); - status = ReportType.Success; - } - catch (Exception e) - { - status = ReportType.Failure; - GeneralTracer.Error( - "The Execute method in the GeneralUpdate.Core.WindowsStrategy class throws an exception.", - e); - EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message)); - } - finally + var context = new PipelineContext(); + //Common + context.Add("ZipFilePath", + Path.Combine(_configinfo.TempPath, $"{version.Name}{_configinfo.Format}")); + //Hash middleware + context.Add("Hash", version.Hash); + //Zip middleware + context.Add("Format", _configinfo.Format); + context.Add("Name", version.Name); + context.Add("Encoding", _configinfo.Encoding); + //Patch middleware + context.Add("SourcePath", _configinfo.InstallPath); + context.Add("PatchPath", patchPath); + context.Add("PatchEnabled", _configinfo.PatchEnabled); + //Driver middleware + if (_configinfo.DriveEnabled == true) { - await VersionService.Report(_configinfo.ReportUrl - , version.RecordId - , status - , version.AppType - , _configinfo.Scheme - , _configinfo.Token); + context.Add("DriverOutPut", StorageManager.GetTempDirectory("DriverOutPut")); + context.Add("FieldMappings", _configinfo.FieldMappings); } - } - if (!string.IsNullOrEmpty(_configinfo.UpdateLogUrl)) + var pipelineBuilder = new PipelineBuilder(context) + .UseMiddlewareIf(_configinfo.PatchEnabled) + .UseMiddleware() + .UseMiddleware() + .UseMiddlewareIf(_configinfo.DriveEnabled); + await pipelineBuilder.Build(); + status = ReportType.Success; + } + catch (Exception e) { - OpenBrowser(_configinfo.UpdateLogUrl); + status = ReportType.Failure; + GeneralTracer.Error( + "The ExecuteAsync method in the GeneralUpdate.Core.LinuxStrategy class throws an exception.", + e); + EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message)); + } + finally + { + await VersionService.Report(_configinfo.ReportUrl + , version.RecordId + , status + , version.AppType + , _configinfo.Scheme + , _configinfo.Token); } - - Clear(patchPath); - Clear(_configinfo.TempPath); - StartApp(); } - catch (Exception e) + + if (!string.IsNullOrEmpty(_configinfo.UpdateLogUrl)) { - GeneralTracer.Error( - "The Execute method in the GeneralUpdate.Core.WindowsStrategy class throws an exception.", e); - EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message)); + OpenBrowser(_configinfo.UpdateLogUrl); } - }); + + Clear(patchPath); + Clear(_configinfo.TempPath); + StartApp(); + } + catch (Exception e) + { + GeneralTracer.Error( + "The ExecuteAsync method in the GeneralUpdate.Core.LinuxStrategy class throws an exception.", e); + EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message)); + } } public override void StartApp() @@ -113,7 +110,7 @@ public override void StartApp() catch (Exception e) { GeneralTracer.Error( - "The StartApp method in the GeneralUpdate.Core.WindowsStrategy class throws an exception.", e); + "The StartApp method in the GeneralUpdate.Core.LinuxStrategy class throws an exception.", e); EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message)); } finally