public void Execute(Package galleryPackage, INupkg nugetPackage, bool commitChanges) { foreach (var curator in GetServices <IAutomaticPackageCurator>()) { curator.Curate(galleryPackage, nugetPackage, commitChanges: commitChanges); } curatedFeedService.UpdateIsLatest(galleryPackage.PackageRegistration, commitChanges); }
private void UpdateIsLatest(PackageRegistration packageRegistration, bool commitChanges) { if (!packageRegistration.Packages.Any()) { return; } // TODO: improve setting the latest bit; this is horrible. Trigger maybe? foreach (var pv in packageRegistration.Packages.Where(p => p.IsLatest || p.IsLatestStable)) { pv.IsLatest = false; pv.IsLatestStable = false; pv.LastUpdated = DateTime.UtcNow; } // If the last listed package was just unlisted, then we won't find another one var latestPackage = FindPackage(packageRegistration.Packages, p => p.Listed); if (latestPackage != null) { latestPackage.IsLatest = true; latestPackage.LastUpdated = DateTime.UtcNow; if (latestPackage.IsPrerelease) { // If the newest uploaded package is a prerelease package, we need to find an older package that is // a release version and set it to IsLatest. var latestReleasePackage = FindPackage(packageRegistration.Packages.Where(p => !p.IsPrerelease && p.Listed)); if (latestReleasePackage != null) { // We could have no release packages latestReleasePackage.IsLatestStable = true; latestReleasePackage.LastUpdated = DateTime.UtcNow; } } else { // Only release versions are marked as IsLatestStable. latestPackage.IsLatestStable = true; } } _curatedFeedService.UpdateIsLatest(packageRegistration, commitChanges); }