diff --git a/projects/IoTDameon/UpdateIoTNodeService.cs b/projects/IoTDameon/UpdateIoTNodeService.cs index f3513da7..5298a64c 100644 --- a/projects/IoTDameon/UpdateIoTNodeService.cs +++ b/projects/IoTDameon/UpdateIoTNodeService.cs @@ -1,6 +1,5 @@ using CookComputing.XmlRpc; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System; @@ -20,16 +19,14 @@ namespace IoTDameon { private readonly ILogger _logger; private readonly IWebHostEnvironment _env; - private readonly IConfiguration _cfg; private readonly IHttpClientFactory _httpClientFactory; public bool IsUpdating { get; set; } - public UpdateIoTNodeService(ILogger logger, IWebHostEnvironment env, IConfiguration cfg, IHttpClientFactory httpClientFactory) + public UpdateIoTNodeService(ILogger logger, IWebHostEnvironment env, IHttpClientFactory httpClientFactory) { this._logger = logger; this._env = env; - this._cfg = cfg; this._httpClientFactory = httpClientFactory; } @@ -40,7 +37,7 @@ namespace IoTDameon while (!stoppingToken.IsCancellationRequested) { this.Update(); - await Task.Delay(1000 * 60, stoppingToken); + await Task.Delay(60 * 10 * 1000, stoppingToken); } await Task.CompletedTask; } @@ -77,7 +74,6 @@ namespace IoTDameon var name = $"{appFolder}.zip"; var backupPath = Path.Combine(root, $"{appFolder}_bk"); var file = Path.Combine(root, name); - var currentCheckSum = string.Empty; //检查是否有更新 this._logger.LogInformation("check last version"); var currentVersion = this._httpClientFactory.CreateClient().GetAsync($"http://localhost:{port}/Home/GetVersion").Result.Content.ReadAsStringAsync().Result; @@ -95,7 +91,7 @@ namespace IoTDameon //查看是否已下载更新并删除旧的更新文件 if (File.Exists(file)) { - currentCheckSum = getCheckSum(file); + var currentCheckSum = GetCheckSum(file); if (currentCheckSum != lastCheckSum) { this._logger.LogWarning($"current file hash {currentCheckSum} does not equals last file hash {lastCheckSum}"); @@ -111,7 +107,7 @@ namespace IoTDameon { fs.Write(bytes); } - currentCheckSum = getCheckSum(file); + var currentCheckSum = GetCheckSum(file); if (currentCheckSum != lastCheckSum) { this._logger.LogWarning($"download file hash {currentCheckSum} does not math hash in xml {lastCheckSum}"); @@ -196,7 +192,7 @@ namespace IoTDameon } } - private string getCheckSum(string file) + private string GetCheckSum(string file) { using (var sha = SHA512.Create()) {