public async Task <Stream> GetPackageContentStreamOrNullAsync( string id, NuGetVersion version, CancellationToken cancellationToken = default) { // Allow read-through caching if it is configured. await _mirror.MirrorAsync(id, version, cancellationToken); if (!await _packages.AddDownloadAsync(id, version)) { return(null); } return(await _storage.GetPackageStreamAsync(id, version, cancellationToken)); }
public async Task <IActionResult> DownloadPackage(string id, string version, CancellationToken cancellationToken) { if (!NuGetVersion.TryParse(version, out var nugetVersion)) { return(NotFound()); } // Allow read-through caching if it is configured. await _mirror.MirrorAsync(id, nugetVersion, cancellationToken); if (!await _packages.AddDownloadAsync(id, nugetVersion)) { return(NotFound()); } var packageStream = await _storage.GetPackageStreamAsync(id, nugetVersion, cancellationToken); return(File(packageStream, "application/octet-stream")); }
public async Task <IActionResult> DownloadPackage(string id, string version) { if (!NuGetVersion.TryParse(version, out var nugetVersion)) { return(NotFound()); } if (!await _packages.ExistsAsync(id, nugetVersion)) { return(NotFound()); } await _packages.AddDownloadAsync(id, nugetVersion); var identity = new PackageIdentity(id, nugetVersion); var packageStream = await _storage.GetPackageStreamAsync(identity); return(File(packageStream, "application/octet-stream")); }
public Task AddDownloadAsync(string id, NuGetVersion version) => _localPackages.AddDownloadAsync(id, version);