Skip to content

Commit

Permalink
(chocolatey#3502) Return the PageSize if specified
Browse files Browse the repository at this point in the history
If a page size has been specified, use it. Also emit a warning if it's
something other than 30 as there are known issues with some feeds.
  • Loading branch information
corbob committed Nov 4, 2024
1 parent 2866df9 commit 258017d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ private async static Task<IQueryable<IPackageSearchMetadata>> SearchPackagesAsyn
{
var takeNumber = GetTakeAmount(configuration);

if (takeNumber != 30)
{
var warning = "The page size has been specified to be {0:N0} packages. There are known issues with some repositories when you use a page size other than 30.".FormatWith(takeNumber);
if (configuration.RegularOutput)
{
"chocolatey".Log().Warn(warning);
}
else
{
"chocolatey".Log().Debug(warning);
}
}

var partResults = new HashSet<IPackageSearchMetadata>(new ComparePackageSearchMetadataIdOnly());
var latestResults = new List<IPackageSearchMetadata>();

Expand Down Expand Up @@ -305,13 +318,10 @@ private async static Task<IQueryable<IPackageSearchMetadata>> SearchPackagesAsyn

private static int GetTakeAmount(ChocolateyConfiguration configuration)
{
// We calculate the amount of items we take at the same time, while making
// sure to take the minimum value of 30 packages which we know is a safe value
// to take from CCR and other feeds to minimize any issues that can happen.

if (configuration.ListCommand.Page.HasValue || configuration.ListCommand.ExplicitPageSize)
{
return Math.Min(configuration.ListCommand.PageSize, 30);
return configuration.ListCommand.PageSize;
}

return 30;
Expand Down

0 comments on commit 258017d

Please sign in to comment.