Skip to content

Commit 89510c5

Browse files
committed
change errors to type concurrentbag
1 parent 44045df commit 89510c5

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/code/FindHelper.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(ServerApiCall curren
11751175
// Method 2
11761176
internal void FindDependencyPackagesHelper(ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository)
11771177
{
1178-
List<ErrorRecord> errors = new List<ErrorRecord>();
1178+
ConcurrentBag<ErrorRecord> errors = new ConcurrentBag<ErrorRecord>();
11791179
if (currentPkg.Dependencies.Length > 0)
11801180
{
11811181
// If finding more than 5 packages, do so concurrently
@@ -1205,23 +1205,23 @@ internal void FindDependencyPackagesHelper(ServerApiCall currentServer, Response
12051205
}
12061206

12071207
// Method 3
1208-
private void FindDependencyPackageVersion(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, List<ErrorRecord> errors)
1208+
private void FindDependencyPackageVersion(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, ConcurrentBag<ErrorRecord> errors)
12091209
{
12101210
PSResourceInfo depPkg = null;
12111211

12121212
if (dep.VersionRange.Equals(VersionRange.All) || !dep.VersionRange.HasUpperBound)
12131213
{
1214-
// Case 1: No upper bound, eg: "*" or "(1.0.0, )"
1215-
// Check if the latest version is cached
1216-
if (_knownLatestPkgVersion.TryGetValue(dep.Name, out PSResourceInfo cachedDepPkg))
1217-
{
1218-
depPkg = cachedDepPkg;
1219-
}
1220-
else
1221-
{
1222-
// Find this version from the server
1223-
depPkg = FindDependencyWithLowerBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errors);
1224-
}
1214+
// Case 1: No upper bound, eg: "*" or "(1.0.0, )"
1215+
// Check if the latest version is cached
1216+
if (_knownLatestPkgVersion.TryGetValue(dep.Name, out PSResourceInfo cachedDepPkg))
1217+
{
1218+
depPkg = cachedDepPkg;
1219+
}
1220+
else
1221+
{
1222+
// Find this version from the server
1223+
depPkg = FindDependencyWithLowerBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errors);
1224+
}
12251225
}
12261226
else if (dep.VersionRange.HasLowerBound && dep.VersionRange.MinVersion.Equals(dep.VersionRange.MaxVersion))
12271227
{
@@ -1257,7 +1257,7 @@ private void FindDependencyPackageVersion(Dependency dep, ServerApiCall currentS
12571257
}
12581258

12591259
// Method 4
1260-
private PSResourceInfo FindDependencyWithSpecificVersion(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, List<ErrorRecord> errors)
1260+
private PSResourceInfo FindDependencyWithSpecificVersion(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, ConcurrentBag<ErrorRecord> errors)
12611261
{
12621262
PSResourceInfo depPkg = null;
12631263
ErrorRecord errRecord = null;
@@ -1320,7 +1320,7 @@ private PSResourceInfo FindDependencyWithSpecificVersion(Dependency dep, ServerA
13201320
}
13211321

13221322
// Method 5
1323-
private PSResourceInfo FindDependencyWithLowerBound(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, List<ErrorRecord> errors)
1323+
private PSResourceInfo FindDependencyWithLowerBound(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, ConcurrentBag<ErrorRecord> errors)
13241324
{
13251325
PSResourceInfo depPkg = null;
13261326
FindResults responses = null;
@@ -1383,7 +1383,7 @@ private PSResourceInfo FindDependencyWithLowerBound(Dependency dep, ServerApiCal
13831383
}
13841384

13851385
// Method 6
1386-
private PSResourceInfo FindDependencyWithUpperBound(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, List<ErrorRecord> errors)
1386+
private PSResourceInfo FindDependencyWithUpperBound(Dependency dep, ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSResourceInfo currentPkg, PSRepositoryInfo repository, ConcurrentBag<ErrorRecord> errors)
13871387
{
13881388
PSResourceInfo depPkg = null;
13891389
ErrorRecord errRecord = null;

src/code/InstallHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ private ConcurrentDictionary<string, Hashtable> BeginPackageInstall(
904904

905905
private ConcurrentDictionary<string, Hashtable> InstallParentAndDependencyPackages(List<PSResourceInfo> parentAndDeps, ServerApiCall currentServer, string tempInstallPath, ConcurrentDictionary<string, Hashtable> packagesHash, ConcurrentDictionary<string, Hashtable> updatedPackagesHash, PSResourceInfo pkgToInstall)
906906
{
907-
List<ErrorRecord> errors = new List<ErrorRecord>();
907+
ConcurrentBag<ErrorRecord> errors = new ConcurrentBag<ErrorRecord>();
908908

909909
// TODO: figure out a good threshold and parallel count
910910
int processorCount = Environment.ProcessorCount;

0 commit comments

Comments
 (0)