Skip to content

Commit 536aed5

Browse files
committed
Few changes
1 parent 4a90f13 commit 536aed5

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/code/FindHelper.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,8 @@ public IEnumerable<PSResourceInfo> FindByTag(
708708
private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSRepositoryInfo repository, bool shouldReportErrorForEachRepo)
709709
{
710710
ErrorRecord errRecord = null;
711+
ConcurrentQueue<ErrorRecord> errorMsgs = new ConcurrentQueue<ErrorRecord>();
712+
ConcurrentQueue<string> debugMsgs = new ConcurrentQueue<string>();
711713
List<PSResourceInfo> parentPkgs = new List<PSResourceInfo>();
712714
string tagsAsString = String.Empty;
713715
bool isV2Resource = currentResponseUtil is V2ResponseUtil;
@@ -904,11 +906,13 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
904906
FindResults responses = null;
905907
if (_tag.Length == 0)
906908
{
909+
910+
907911
ConcurrentDictionary<string, Task<FindResults>> cachedNetworkCalls = new ConcurrentDictionary<string, Task<FindResults>>();
908912
Task<FindResults> response = null;
909913
if (currentServer.Repository.ApiVersion == PSRepositoryInfo.APIVersion.V2) {
910914
string key = $"{pkgName}|{_nugetVersion.ToNormalizedString()}|{_type}";
911-
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionAsync(pkgName, _nugetVersion.ToNormalizedString(), _type));
915+
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionAsync(pkgName, _nugetVersion.ToNormalizedString(), _type, errorMsgs, debugMsgs));
912916

913917
responses = response.GetAwaiter().GetResult();
914918

@@ -993,7 +997,7 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
993997
Task<FindResults> response = null;
994998
if (currentServer.Repository.ApiVersion == PSRepositoryInfo.APIVersion.V2) {
995999
string key = $"{pkgName}|{_versionRange.ToString()}|{_type}";
996-
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionGlobbingAsync(pkgName, _versionRange, _prerelease, _type, getOnlyLatest: false));
1000+
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionGlobbingAsync(pkgName, _versionRange, _prerelease, _type, getOnlyLatest: false, errorMsgs, debugMsgs));
9971001

9981002
responses = response.GetAwaiter().GetResult();
9991003
}
@@ -1250,7 +1254,7 @@ private void FindDependencyPackageVersion(
12501254
else
12511255
{
12521256
// Find this version from the server
1253-
depPkg = FindDependencyWithLowerBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, debugMsgs);
1257+
depPkg = FindDependencyWithLowerBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, verboseMsgs);
12541258
}
12551259
}
12561260
else if (dep.VersionRange.HasLowerBound && dep.VersionRange.MinVersion.Equals(dep.VersionRange.MaxVersion))
@@ -1267,7 +1271,7 @@ private void FindDependencyPackageVersion(
12671271
}
12681272
else
12691273
{
1270-
depPkg = FindDependencyWithSpecificVersion(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, debugMsgs);
1274+
depPkg = FindDependencyWithSpecificVersion(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, verboseMsgs, warningMsgs);
12711275
}
12721276
}
12731277
else
@@ -1283,7 +1287,7 @@ private void FindDependencyPackageVersion(
12831287
}
12841288
else
12851289
{
1286-
depPkg = FindDependencyWithUpperBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, debugMsgs);
1290+
depPkg = FindDependencyWithUpperBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errorMsgs, verboseMsgs);
12871291
}
12881292
}
12891293
}
@@ -1309,7 +1313,7 @@ private PSResourceInfo FindDependencyWithSpecificVersion(
13091313
// See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
13101314
string key = $"{dep.Name}|{dep.VersionRange.MaxVersion.ToString()}|{_type}";
13111315
verboseMsgs.Enqueue("Checking if network call is cached.");
1312-
response = _cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionAsync(dep.Name, dep.VersionRange.MaxVersion.ToString(), _type));
1316+
response = _cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionAsync(dep.Name, dep.VersionRange.MaxVersion.ToString(), _type, errorMsgs, verboseMsgs));
13131317

13141318
responses = response.GetAwaiter().GetResult();
13151319
}
@@ -1382,7 +1386,7 @@ private PSResourceInfo FindDependencyWithLowerBound(
13821386
// See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
13831387
string key = $"{dep.Name}|*|{_type}";
13841388
verboseMsgs.Enqueue("Checking if network call is cached.");
1385-
response = _cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindNameAsync(dep.Name, includePrerelease: true, _type));
1389+
response = _cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindNameAsync(dep.Name, includePrerelease: true, _type, errorMsgs, verboseMsgs));
13861390

13871391
responses = response.GetAwaiter().GetResult();
13881392
}
@@ -1456,7 +1460,7 @@ private PSResourceInfo FindDependencyWithUpperBound(
14561460
// See if the network call we're making is already caced, if not, call FindNameAsync() and cache results
14571461
string key = $"{dep.Name}|{dep.VersionRange.MaxVersion.ToString()}|{_type}";
14581462
verboseMsgs.Enqueue("Checking if network call is cached.");
1459-
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionGlobbingAsync(dep.Name, dep.VersionRange, includePrerelease: true, ResourceType.None, getOnlyLatest: true));
1463+
response = cachedNetworkCalls.GetOrAdd(key, _ => currentServer.FindVersionGlobbingAsync(dep.Name, dep.VersionRange, includePrerelease: true, ResourceType.None, getOnlyLatest: true, errorMsgs, verboseMsgs));
14601464

14611465
responses = response.GetAwaiter().GetResult();
14621466

src/code/InstallHelper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ private ConcurrentDictionary<string, Hashtable> BeginPackageInstall(
639639
out string warning,
640640
out ErrorRecord errRecord)
641641
{
642-
_cmdletPassedIn.WriteDebug("In InstallHelper::InstallPackage()");
642+
_cmdletPassedIn.WriteDebug("In InstallHelper::BeginPackageInstall()");
643643
FindResults responses = null;
644644
warning = null;
645645
errRecord = null;
@@ -826,7 +826,7 @@ private ConcurrentDictionary<string, Hashtable> BeginPackageInstall(
826826
// List returned only includes dependencies, so we'll add the parent pkg to this list to pass on to installation method
827827
parentAndDeps.Add(pkgToInstall);
828828

829-
_cmdletPassedIn.WriteDebug("In InstallHelper::InstallPackage(), found all dependencies");
829+
_cmdletPassedIn.WriteDebug("In InstallHelper::BeginPackageInstall(), found all dependencies");
830830

831831
return InstallParentAndDependencyPackages(parentAndDeps, currentServer, tempInstallPath, packagesHash, updatedPackagesHash, pkgToInstall);
832832
}
@@ -876,7 +876,9 @@ private ConcurrentDictionary<string, Hashtable> InstallParentAndDependencyPackag
876876
var depPkgVersion = depPkg.Version.ToString();
877877

878878
verboseMsgs.Enqueue($"Installing package '{depPkgName}' version '{depPkgVersion}'");
879-
Stream responseStream = currentServer.InstallPackage(depPkgName, depPkgVersion, true, out ErrorRecord installNameErrRecord);
879+
//Stream responseStream = currentServer.InstallPackage(depPkgName, depPkgVersion, true, out ErrorRecord installNameErrRecord);
880+
// add async
881+
Stream responseStream = currentServer.InstallPackageAsync(depPkgName, depPkgVersion, true, out ErrorRecord installNameErrRecord, errorMsgs, verboseMsgs);
880882

881883
if (installNameErrRecord != null)
882884
{

0 commit comments

Comments
 (0)