Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#3433) Add overload for FindPackages method #3454

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private async static Task<IQueryable<IPackageSearchMetadata>> SearchPackagesAsyn
}
else
{
var exactPackage = FindPackage(searchTermLower, configuration, nugetLogger, cacheContext, packageRepositoryResources, version);
var exactPackage = FindPackage(searchTermLower, configuration, nugetLogger, (SourceCacheContext)cacheContext, packageRepositoryResources, version);

if (exactPackage == null)
{
Expand Down Expand Up @@ -342,6 +342,28 @@ public static ISet<IPackageSearchMetadata> FindAllPackageVersions(string package
return metadataList;
}

/// <summary>
/// Searches for packages that are available based on name and other options
/// </summary>
/// <param name="packageName">Name of package to search for</param>
/// <param name="config">Chocolatey configuration used to help supply the search parameters</param>
/// <param name="nugetLogger">The nuget logger</param>
/// <param name="resources">The resources that should be queried</param>
/// <param name="version">Version to search for</param>
/// <param name="cacheContext">Settings for caching of results from sources</param>
/// <returns>One result or nothing</returns>
[Obsolete("Use the overload that uses the base source cache context instead.")]
public static IPackageSearchMetadata FindPackage(
string packageName,
ChocolateyConfiguration config,
ILogger nugetLogger,
ChocolateySourceCacheContext cacheContext,
IEnumerable<NuGetEndpointResources> resources,
NuGetVersion version)
{
return FindPackage(packageName, config, nugetLogger, (SourceCacheContext)cacheContext, resources, version);
}

/// <summary>
/// Searches for packages that are available based on name and other options
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public virtual ConcurrentDictionary<string, PackageResult> Install(ChocolateyCon
latestPackageVersion = version;
}

var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, sourceCacheContext, remoteEndpoints, latestPackageVersion);
var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, latestPackageVersion);

if (availablePackage == null)
{
Expand Down Expand Up @@ -1149,7 +1149,7 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
// this is a prerelease - opt in for newer prereleases.
config.Prerelease = true;
}
var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, sourceCacheContext, remoteEndpoints, version);
var availablePackage = NugetList.FindPackage(packageName, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, version);

config.Prerelease = originalPrerelease;

Expand Down Expand Up @@ -1334,7 +1334,7 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
{
if (version != null)
{
var requestedPackageDependency = NugetList.FindPackage(parentPackage.Id, config, _nugetLogger, sourceCacheContext, remoteEndpoints, version);
var requestedPackageDependency = NugetList.FindPackage(parentPackage.Id, config, _nugetLogger, (SourceCacheContext)sourceCacheContext, remoteEndpoints, version);

if (requestedPackageDependency != null)
{
Expand Down
Loading