Skip to content

Commit

Permalink
Don't enumerate non existent directories in NuGetPackageLocator
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Sep 21, 2024
1 parent f4e9d2c commit d7a736e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dnSpy/dnSpy.Contracts.Logic/Utilities/NuGetPackageLocator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using NuGet.Configuration;

Expand Down Expand Up @@ -38,7 +39,7 @@ static NuGetPackageLocator() {
public static IReadOnlyList<IReadOnlyList<string>> GetPossibleNuGetPackageLocations(string packageName, string? packageVersion) =>
GetPossibleNuGetPackageLocations(new NuGetPackageInfo(packageName, packageVersion));

static IReadOnlyList<IReadOnlyList<string>> GetPossibleNuGetPackageLocations(NuGetPackageInfo packageInfo) {
static List<IReadOnlyList<string>> GetPossibleNuGetPackageLocations(NuGetPackageInfo packageInfo) {
var packageSources = new List<IReadOnlyList<string>>();

// This is the directory to which packages are downloaded to
Expand Down Expand Up @@ -69,6 +70,9 @@ static IReadOnlyList<IReadOnlyList<string>> GetPossibleNuGetPackageLocations(NuG
}

static IReadOnlyList<string> FindPackages(string packageStore, NuGetPackageInfo packageInfo) {
if (!Directory.Exists(packageStore))
return Array.Empty<string>();

var result = new List<string>();

string[] packages = Directory.GetDirectories(packageStore);
Expand Down

0 comments on commit d7a736e

Please sign in to comment.