Skip to content

Commit da8c25a

Browse files
committed
Fix certain results not appearing on Chocolatey (fix #3421 for the third time)
1 parent 6ce0ab6 commit da8c25a

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ImplicitUsings>enable</ImplicitUsings>
44
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
5-
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
5+
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
66
<SdkVersion>8.0.405</SdkVersion>
77
<Authors>Martí Climent and the contributors</Authors>
88
<PublisherName>Martí Climent</PublisherName>

src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@ protected sealed override IReadOnlyList<Package> FindPackages_UnSafe(string quer
5858

5959
foreach(IManagerSource source in sources)
6060
{
61-
string sortingPiece = "&$orderby=Published%20desc";
62-
if (source.Url.Host == "www.powershellgallery.com") sortingPiece = "";
63-
Uri SearchUrl = new($"{source.Url}/Search()?searchTerm=%27{HttpUtility.UrlEncode(query)}%27&targetFramework=%27%27&includePrerelease=false{sortingPiece}");
61+
Uri? SearchUrl = new($"{source.Url}/Search()?$filter=IsLatestVersion&$orderby=Id&searchTerm='{HttpUtility.UrlEncode(query)}'&targetFramework=''&includePrerelease=false&$skip=0&$top=50&semVerLevel=2.0.0");
62+
// Uri SearchUrl = new($"{source.Url}/Search()?$filter=IsLatestVersion&searchTerm=%27{HttpUtility.UrlEncode(query)}%27&targetFramework=%27%27&includePrerelease=false");
6463
logger.Log($"Begin package search with url={SearchUrl} on manager {Name}");
6564
Dictionary<string, SearchResult> AlreadyProcessedPackages = [];
6665

6766

6867
using HttpClient client = new(CoreData.GenericHttpClientParameters);
6968
client.DefaultRequestHeaders.UserAgent.ParseAdd(CoreData.UserAgentString);
69+
70+
while (SearchUrl is not null)
71+
{
7072
HttpResponseMessage response = client.GetAsync(SearchUrl).GetAwaiter().GetResult();
7173

7274
if (!response.IsSuccessStatusCode)
7375
{
7476
logger.Error($"Failed to fetch api at Url={SearchUrl} with status code {response.StatusCode}");
77+
SearchUrl = null;
7578
continue;
7679
}
7780

@@ -96,8 +99,18 @@ protected sealed override IReadOnlyList<Package> FindPackages_UnSafe(string quer
9699
continue;
97100
}
98101

99-
AlreadyProcessedPackages[id] = new SearchResult { id = id, version = version, version_float = float_version };
102+
AlreadyProcessedPackages[id] =
103+
new SearchResult { id = id, version = version, version_float = float_version };
104+
}
105+
106+
SearchUrl = null;
107+
Match next = Regex.Match(SearchResults, "<link rel=\"next\" href=\"([^\"]+)\" ?\\/>");
108+
if (next.Success)
109+
{
110+
SearchUrl = new Uri(next.Groups[1].Value.Replace("&amp;", "&"));
111+
logger.Log($"Adding extra info from URL={SearchUrl}");
100112
}
113+
}
101114

102115
foreach (SearchResult package in AlreadyProcessedPackages.Values)
103116
{

0 commit comments

Comments
 (0)