public Result InstallOrUpgrade(string version, IMessagePresenter presenter) { string cafeStaging = Path.Combine(_updaterDirectory, "staging"); var installer = _resolver.FullPathToStagedInstaller(version); if (!_commands.FileExists(installer)) { Logger.Error("File is not staged at {installer}. Run download first"); return(Result.Failure( $"Could not install cafe {version} because there is no installer staged at {installer}. Run download first.")); } Logger.Info($"Copying {installer} to {cafeStaging} to be processed by the updater"); File.Copy(installer, Path.Combine(cafeStaging, Path.GetFileName(installer))); Logger.Info($"This service will stop soon and be updated to version {version}"); return(Result.Successful()); }
public Result Download(string version, IMessagePresenter messagePresenter) { messagePresenter.ShowMessage("Ensuring staging directory exists"); _fileSystem.EnsureDirectoryExists(StagingDirectory); var destination = _downloadUrlResolver.FullPathToStagedInstaller(version); if (_fileSystem.FileExists(destination)) { messagePresenter.ShowMessage($"Download msi already exists, so not downloading again"); return(Result.Successful()); } var downloadLink = _downloadUrlResolver.DownloadUriFor(version); messagePresenter.ShowMessage($"Downloading {_product} {version} from {downloadLink}"); var result = _fileDownloader.Download(downloadLink, destination); messagePresenter.ShowMessage($"Finished downloading {_product} {version} from {downloadLink}"); Logger.Info(result); return(result.TranslateIfFailed($"Installer for {_product} {version} could not be found at {downloadLink}")); }
private string StagedInstallerFor(string version) { var fullPathToStagedInstaller = _downloadUrlResolver.FullPathToStagedInstaller(version); return(fullPathToStagedInstaller); }