示例#1
0
        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);
        }
示例#2
0
 /// <summary>
 /// Deletes any previously downloaded installers in the Upgrader Download directory.
 /// This can include old installers which were downloaded, but user never installed
 /// using gvfs upgrade and GVFS is now up to date already.
 /// </summary>
 public static void DeleteAllInstallerDownloads(ITracer tracer = null)
 {
     try
     {
         RecursiveDelete(ProductUpgraderInfo.GetAssetDownloadsPath());
     }
     catch (Exception ex)
     {
         if (tracer != null)
         {
             tracer.RelatedError($"{nameof(DeleteAllInstallerDownloads)}: Could not remove directory: {ProductUpgraderInfo.GetAssetDownloadsPath()}.{ex.ToString()}");
         }
     }
 }
示例#3
0
 public void DeleteAllInstallerDownloads()
 {
     try
     {
         this.fileSystem.DeleteDirectory(GetAssetDownloadsPath());
     }
     catch (Exception ex)
     {
         if (this.tracer != null)
         {
             this.tracer.RelatedError($"{nameof(this.DeleteAllInstallerDownloads)}: Could not remove directory: {ProductUpgraderInfo.GetAssetDownloadsPath()}.{ex.ToString()}");
         }
     }
 }