private async Task <bool> ProcessPackageDetailsViaHttpAsync( HttpClient client, string id, string version, Uri sourceUri, PackageDetailsCatalogLeaf catalogLeaf, Dictionary <string, string> telemetryProperties, CancellationToken cancellationToken) { var packageDownloader = new PackageDownloader(client, _logger); var requestUri = Utilities.GetNugetCacheBustingUri(sourceUri); using (var stream = await packageDownloader.DownloadAsync(requestUri, cancellationToken)) { if (stream == null) { _logger.LogWarning("Package {Id}/{Version} not found.", id, version); return(false); } telemetryProperties[TelemetryConstants.SizeInBytes] = stream.Length.ToString(); var nuspec = GetNuspec(stream, id); if (nuspec == null) { _logger.LogWarning("No .nuspec available for {Id}/{Version}. Skipping.", id, version); return(false); } stream.Position = 0; await _dnxMaker.AddPackageAsync( stream, nuspec, id, version, catalogLeaf.IconFile, cancellationToken); } _logger.LogInformation("Added .nupkg and .nuspec for package {Id}/{Version}", id, version); return(true); }
private async Task <PrimarySignature> GetPrimarySignatureOrNullAsync(ValidationContext context) { var downloader = new PackageDownloader(context.Client, Logger); var uri = GetV3PackageUri(context); using (var packageStream = await downloader.DownloadAsync(uri, context.CancellationToken)) { if (packageStream == null) { throw new InvalidOperationException($"Package {context.Package.Id} {context.Package.Version} couldn't be downloaded at {uri}"); } using (var package = new PackageArchiveReader(packageStream)) { return(await package.GetPrimarySignatureAsync(context.CancellationToken)); } } }
private async Task <bool> ProcessPackageDetailsViaHttpAsync( HttpClient client, string id, string version, Uri sourceUri, CancellationToken cancellationToken) { var packageDownloader = new PackageDownloader(client, _logger); var requestUri = Utilities.GetNugetCacheBustingUri(sourceUri); using (var stream = await packageDownloader.DownloadAsync(requestUri, cancellationToken)) { if (stream == null) { _logger.LogWarning("Package {Id}/{Version} not found.", id, version); return(false); } var nuspec = GetNuspec(stream, id); if (nuspec == null) { _logger.LogWarning("No .nuspec available for {Id}/{Version}. Skipping.", id, version); return(false); } stream.Position = 0; await _dnxMaker.AddPackageAsync( stream, nuspec, id, version, cancellationToken); } _logger.LogInformation("Added .nupkg and .nuspec for package {Id}/{Version}", id, version); return(true); }