public static GitHubUpgrader Create( ITracer tracer, PhysicalFileSystem fileSystem, bool dryRun, bool noVerify, LocalGVFSConfig localConfig, out string error) { GitHubUpgrader upgrader = null; GitHubUpgraderConfig gitHubUpgraderConfig = new GitHubUpgraderConfig(tracer, localConfig); if (!gitHubUpgraderConfig.TryLoad(out error)) { return(null); } if (gitHubUpgraderConfig.ConfigError()) { gitHubUpgraderConfig.ConfigAlertMessage(out error); return(null); } upgrader = new GitHubUpgrader( ProcessHelper.GetCurrentProcessVersion(), tracer, fileSystem, gitHubUpgraderConfig, dryRun, noVerify); return(upgrader); }
protected virtual bool TryDownloadAsset(Asset asset, out string errorMessage) { errorMessage = null; string downloadPath = ProductUpgraderInfo.GetAssetDownloadsPath(); Exception exception; if (!GitHubUpgrader.TryCreateDirectory(downloadPath, out exception)) { errorMessage = exception.Message; this.TraceException(exception, nameof(this.TryDownloadAsset), $"Error creating download directory {downloadPath}."); return(false); } string localPath = Path.Combine(downloadPath, asset.Name); WebClient webClient = new WebClient(); try { webClient.DownloadFile(asset.DownloadURL, localPath); asset.LocalPath = localPath; } catch (WebException webException) { errorMessage = "Download error: " + exception.Message; this.TraceException(webException, nameof(this.TryDownloadAsset), $"Error downloading asset {asset.Name}."); return(false); } return(true); }
public static bool TryCreateUpgrader( out IProductUpgrader newUpgrader, ITracer tracer, out string error) { newUpgrader = GitHubUpgrader.Create(tracer, out error); if (newUpgrader == null) { tracer.RelatedError($"{nameof(TryCreateUpgrader)}: Could not create upgrader. {error}"); return(false); } return(true); }
public static GitHubUpgrader Create(LocalGVFSConfig localConfig, ITracer tracer, out string error) { GitHubUpgrader upgrader = null; GitHubUpgraderConfig gitHubUpgraderConfig = new GitHubUpgraderConfig(tracer, localConfig); if (!gitHubUpgraderConfig.TryLoad(out error)) { return(null); } if (gitHubUpgraderConfig.ConfigError()) { gitHubUpgraderConfig.ConfigAlertMessage(out error); return(null); } upgrader = new GitHubUpgrader( ProcessHelper.GetCurrentProcessVersion(), tracer, gitHubUpgraderConfig); return(upgrader); }