protected override async Task OnTimer() { try { //Skip if network not available if (!NetworkStatus.CanDownload(_downloadNetworkPriority)) { _logger?.LogInformation($"Skip package download due to network not allowed to download."); return; } _logger?.LogDebug($"Running package updater. Downloading {this.PackageVersion}."); PackageVersionInfo packageVersion = await GetPackageVersionInformation(); var desiredVersion = UpdateUtility.ParseVersion(packageVersion.Version); Version installedVersion = GetInstalledVersion(); if (desiredVersion.CompareTo(installedVersion) != 0) { _logger?.LogInformation($"The desired version of {desiredVersion} is different to installed version {installedVersion}."); await DownloadAndInstallNewVersionAsync(packageVersion); } } catch (Exception ex) { _logger?.LogError($"Error download {this.PackageVersion}. Exception: {ex.ToMinimized()}"); } }
protected async override Task OnTimer() { try { //Skip if network not available if (!NetworkStatus.CanDownload(_downloadNetworkPriority)) { _logger?.LogInformation($"Skip configuration download due to network not allowed to download."); return; } _logger?.LogDebug($"Running config updater. Downloading {this.Source}."); var configDownloader = UpdateUtility.CreateDownloaderFromUrl(this.Source, _context); string newConfig = await configDownloader.ReadFileAsStringAsync(this.Source); string configPath = UpdateUtility.ResolvePath(this.Destination); if (!File.Exists(configPath) || !newConfig.Equals(File.ReadAllText(configPath))) { _logger?.LogInformation($"Config file changed. Updating configuration file."); File.WriteAllText(configPath, newConfig); } } catch (Exception ex) { _logger?.LogError($"Error download {this.Source}. Exception: {ex.ToMinimized()}"); } }