From d7a736ef081360b57c03bc806e8546b8b1c2fed3 Mon Sep 17 00:00:00 2001 From: ElektroKill Date: Sat, 21 Sep 2024 11:22:41 +0200 Subject: [PATCH] Don't enumerate non existent directories in `NuGetPackageLocator` --- .../Utilities/NuGetPackageLocator.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dnSpy/dnSpy.Contracts.Logic/Utilities/NuGetPackageLocator.cs b/dnSpy/dnSpy.Contracts.Logic/Utilities/NuGetPackageLocator.cs index 4af7f0070a..f1862ca0ff 100644 --- a/dnSpy/dnSpy.Contracts.Logic/Utilities/NuGetPackageLocator.cs +++ b/dnSpy/dnSpy.Contracts.Logic/Utilities/NuGetPackageLocator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using NuGet.Configuration; @@ -38,7 +39,7 @@ static NuGetPackageLocator() { public static IReadOnlyList> GetPossibleNuGetPackageLocations(string packageName, string? packageVersion) => GetPossibleNuGetPackageLocations(new NuGetPackageInfo(packageName, packageVersion)); - static IReadOnlyList> GetPossibleNuGetPackageLocations(NuGetPackageInfo packageInfo) { + static List> GetPossibleNuGetPackageLocations(NuGetPackageInfo packageInfo) { var packageSources = new List>(); // This is the directory to which packages are downloaded to @@ -69,6 +70,9 @@ static IReadOnlyList> GetPossibleNuGetPackageLocations(NuG } static IReadOnlyList FindPackages(string packageStore, NuGetPackageInfo packageInfo) { + if (!Directory.Exists(packageStore)) + return Array.Empty(); + var result = new List(); string[] packages = Directory.GetDirectories(packageStore);