/// <summary> /// Downloads and imports a remote key file. /// </summary> /// <exception cref="WebException">The key file could not be downloaded from the internet.</exception> /// <exception cref="SignatureException">The downloaded key file is damaged.</exception> /// <exception cref="IOException">A problem occurs while writing trust configuration.</exception> /// <exception cref="UnauthorizedAccessException">Write access to the trust configuration is not permitted.</exception> private void DownloadKey([NotNull] Uri keyUri) { var download = new DownloadMemory(keyUri); _handler.RunTask(download); try { _openPgp.ImportKey(download.GetData()); } #region Error handling catch (InvalidDataException ex) { // Wrap exception since only certain exception types are allowed throw new SignatureException(ex.Message, ex); } #endregion }
/// <inheritdoc/> public Catalog DownloadCatalog(FeedUri source) { #region Sanity checks if (source == null) { throw new ArgumentNullException(nameof(source)); } #endregion if (source.IsFile) { return(XmlStorage.LoadXml <Catalog>(source.LocalPath)); } var download = new DownloadMemory(source); _handler.RunTask(download); var data = download.GetData(); _trustManager.CheckTrust(data, source); return(XmlStorage.LoadXml <Catalog>(new MemoryStream(data))); }
private void Download(FeedUri feedUri) { SetLastCheckAttempt(feedUri); try { var download = new DownloadMemory(feedUri); _handler.RunTask(download); ImportFeed(download.GetData(), feedUri); } catch (WebException ex) when(!feedUri.IsLoopback) { if (_handler.Verbosity == Verbosity.Batch) { Log.Info(string.Format(Resources.FeedDownloadError, feedUri) + " " + Resources.TryingFeedMirror); } else { Log.Warn(string.Format(Resources.FeedDownloadError, feedUri) + " " + Resources.TryingFeedMirror); } try { var download = new DownloadMemory(GetMirrorUrl(feedUri)) { NoCache = Refresh }; _handler.RunTask(download); ImportFeed(download.GetData(), feedUri); } catch (WebException) { // Report the original problem instead of mirror errors throw ex.PreserveStack(); } } }