public async Task <PackageVersionsResponse> GetPackageVersionsOrNullAsync( string id, CancellationToken cancellationToken = default) { // First, attempt to find all package versions using the upstream source. var versions = await _mirror.FindPackageVersionsOrNullAsync(id, cancellationToken); if (versions == null) { // Fallback to the local packages if mirroring is disabled. var packages = await _packages.FindAsync(id, includeUnlisted : true, cancellationToken); if (!packages.Any()) { return(null); } versions = packages.Select(p => p.Version).ToList(); } return(new PackageVersionsResponse { Versions = versions .Select(v => v.ToNormalizedString()) .Select(v => v.ToLowerInvariant()) .ToList() }); }
public async Task <PackageVersionsResponse> GetPackageVersionsOrNullAsync(string id, CancellationToken cancellationToken = default) { // First, attempt to find all package versions using the upstream source. var versions = await _mirror.FindPackageVersionsOrNullAsync(id, cancellationToken); if (versions == null) { // Fallback to the local packages if mirroring is disabled. var packages = await _packages.FindAsync(id); if (!packages.Any()) { return(null); } versions = packages.Select(p => p.Version).ToList(); } return(new PackageVersionsResponse(versions)); }
public async Task <IActionResult> Versions(string id, CancellationToken cancellationToken) { // First, attempt to find all package versions using the upstream source. var versions = await _mirror.FindPackageVersionsOrNullAsync(id, cancellationToken); if (versions == null) { // Fallback to the local packages if the package couldn't be found // on the upstream source. var packages = await _packages.FindAsync(id); if (!packages.Any()) { return(NotFound()); } versions = packages.Select(p => p.Version).ToList(); } return(Json(new PackageVersions(versions))); }