public async Task IndexAsync(Package package, CancellationToken cancellationToken) { var packages = await _packages.FindAsync(package.Id, includeUnlisted : false, cancellationToken); var actions = _actionBuilder.UpdatePackage( new PackageRegistration( package.Id, packages)); await _batchIndexer.IndexAsync(actions, cancellationToken); }
public async Task <IReadOnlyList <NuGetVersion> > FindPackageVersionsAsync( string id, CancellationToken cancellationToken) { var upstreamVersions = await _upstream.ListPackageVersionsAsync(id, cancellationToken); // Merge the local package versions into the upstream package versions. var localPackages = await _db.FindAsync(id, includeUnlisted : true, cancellationToken); var localVersions = localPackages.Select(p => p.Version); if (!upstreamVersions.Any()) { return(localVersions.ToList()); } if (!localPackages.Any()) { return(upstreamVersions); } return(upstreamVersions.Concat(localVersions).Distinct().ToList()); }