public bool ScheduleInstallUpdate(UpdateInfo updateInfo, string filePath) { _logger.Info($"Shedule install update with version: {updateInfo.GetVersion()}"); if (File.Exists(filePath)) { _updateRepository.SetCurrentVersion(Program.Version.ToString(3)); try { if (!Directory.Exists(_updatesStoragePath)) { Directory.CreateDirectory(_updatesStoragePath); } if (File.Exists(_schedInstallArchivePath)) { File.Delete(_schedInstallArchivePath); } File.Move(filePath, _schedInstallArchivePath); if (JsonHelper.WriteFile(_schedInstallJsonPath, updateInfo)) { _updateRepository.SetCurrentVersion(updateInfo.GetVersion()); return(true); } _logger.Error($"Failed write schedule json: {_schedInstallJsonPath}"); return(false); } catch (Exception e) { _logger.Error(e, $"Exception during schedule install update at: {filePath}"); CancelScheduleInstallUpdate(); return(false); } } _logger.Error($"No schedule update package: {filePath}"); return(false); }
public bool ScheduleInstallUpdate(UpdateInfo updateInfo, string filePath) { if (File.Exists(filePath)) { _updateRepository.SetCurrentVersion(Program.Version.ToString(3)); try { if (!Directory.Exists(_updatesStoragePath)) { Directory.CreateDirectory(_updatesStoragePath); } if (File.Exists(_schedInstallArchivePath)) { File.Delete(_schedInstallArchivePath); } File.Move(filePath, _schedInstallArchivePath); if (JsonHelper.WriteFile(_schedInstallJsonPath, updateInfo)) { _updateRepository.SetCurrentVersion(updateInfo.GetVersion()); return(true); } } catch { CancelScheduleInstallUpdate(); return(false); } } return(false); }
public UpdateInfo?UpdateCurrentVersion(string?fallbackVersion) { UpdateInfo?foundVersion = null; if (UpdateReleases != null && UpdateReleases.Any()) { var searchVersion = CurrentVersion ?? fallbackVersion; if (searchVersion != null) { foundVersion = UpdateReleases.SingleOrDefault(li => string.Compare(li.GetVersion(), searchVersion, StringComparison.OrdinalIgnoreCase) == 0); } foundVersion ??= UpdateReleases.FirstOrDefault(); } CurrentVersion = foundVersion?.GetVersion() ?? fallbackVersion; return(foundVersion); }
public bool IsAlreadyInstalledVersion(UpdateInfo updateInfo) => string.Compare(updateInfo.GetVersion(), Program.Version.ToString(3), StringComparison.OrdinalIgnoreCase) == 0;
public void ApplyScheduledUpdateProps(UpdateInfo updateInfo) => _updateRepository.SetCurrentVersion(updateInfo.GetVersion());