@@ -912,17 +912,12 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
912912
913913 ConcurrentDictionary < string , Task < FindResults > > cachedNetworkCalls = new ConcurrentDictionary < string , Task < FindResults > > ( ) ;
914914 Task < FindResults > response = null ;
915- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 ) {
916- string key = $ "{ pkgName } |{ _nugetVersion . ToNormalizedString ( ) } |{ _type } ";
917- response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionAsync ( pkgName , _nugetVersion . ToNormalizedString ( ) , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
918-
919- responses = response . GetAwaiter ( ) . GetResult ( ) ;
915+ string key = $ "{ pkgName } |{ _nugetVersion . ToNormalizedString ( ) } |{ _type } ";
916+ response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionAsync ( pkgName , _nugetVersion . ToNormalizedString ( ) , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
917+
918+ responses = response . GetAwaiter ( ) . GetResult ( ) ;
920919
921- Utils . WriteOutConcurrentQueue ( _cmdletPassedIn , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ;
922- }
923- else {
924- responses = currentServer . FindVersion ( pkgName , _nugetVersion . ToNormalizedString ( ) , _type , out errRecord ) ;
925- }
920+ Utils . WriteOutConcurrentQueue ( _cmdletPassedIn , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ;
926921 }
927922 else
928923 {
@@ -996,15 +991,10 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
996991 {
997992 ConcurrentDictionary < string , Task < FindResults > > cachedNetworkCalls = new ConcurrentDictionary < string , Task < FindResults > > ( ) ;
998993 Task < FindResults > response = null ;
999- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 ) {
1000- string key = $ "{ pkgName } |{ _versionRange . ToString ( ) } |{ _type } ";
1001- response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionGlobbingAsync ( pkgName , _versionRange , _prerelease , _type , getOnlyLatest : false , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1002-
1003- responses = response . GetAwaiter ( ) . GetResult ( ) ;
1004- }
1005- else {
1006- responses = currentServer . FindVersionGlobbing ( pkgName , _versionRange , _prerelease , _type , getOnlyLatest : false , out errRecord ) ;
1007- }
994+ string key = $ "{ pkgName } |{ _versionRange . ToString ( ) } |{ _type } ";
995+ response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionGlobbingAsync ( pkgName , _versionRange , _prerelease , _type , getOnlyLatest : false , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
996+
997+ responses = response . GetAwaiter ( ) . GetResult ( ) ;
1008998 }
1009999 else
10101000 {
@@ -1189,7 +1179,7 @@ internal void FindDependencyPackagesHelper(ServerApiCall currentServer, Response
11891179 //const int PARALLEL_THRESHOLD = 5; // TODO: Trottle limit from user, defaults to 5;
11901180 int processorCount = Environment . ProcessorCount ;
11911181 int maxDegreeOfParallelism = processorCount * 4 ;
1192- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 && currentPkg . Dependencies . Length > processorCount )
1182+ if ( currentPkg . Dependencies . Length > processorCount )
11931183 {
11941184 Parallel . ForEach ( currentPkg . Dependencies , new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism } , dep =>
11951185 {
@@ -1293,20 +1283,13 @@ private PSResourceInfo FindDependencyWithSpecificVersion(
12931283 Task < FindResults > response = null ;
12941284 debugMsgs . Enqueue ( "In FindHelper::FindDependencyWithSpecificVersion()" ) ;
12951285
1296- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 )
1297- {
1298- // See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
1299- string key = $ "{ dep . Name } |{ dep . VersionRange . MaxVersion . ToString ( ) } |{ _type } ";
1300- debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1301- response = _cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionAsync ( dep . Name , dep . VersionRange . MaxVersion . ToString ( ) , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1302-
1303- responses = response . GetAwaiter ( ) . GetResult ( ) ;
1304- }
1305- else
1306- {
1307- responses = currentServer . FindVersion ( dep . Name , dep . VersionRange . MaxVersion . ToString ( ) , _type , out errRecord ) ;
1308- }
1309-
1286+
1287+ // See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
1288+ string key = $ "{ dep . Name } |{ dep . VersionRange . MaxVersion . ToString ( ) } |{ _type } ";
1289+ debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1290+ response = _cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionAsync ( dep . Name , dep . VersionRange . MaxVersion . ToString ( ) , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1291+
1292+ responses = response . GetAwaiter ( ) . GetResult ( ) ;
13101293
13111294 // Error handling and Convert to PSResource object
13121295 if ( errRecord != null )
@@ -1369,19 +1352,12 @@ private PSResourceInfo FindDependencyWithLowerBound(
13691352 Task < FindResults > response = null ;
13701353 debugMsgs . Enqueue ( "In FindHelper::FindDependencyWithLowerBound()" ) ;
13711354
1372- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 )
1373- {
1374- // See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
1375- string key = $ "{ dep . Name } |*|{ _type } ";
1376- debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1377- response = _cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindNameAsync ( dep . Name , includePrerelease : true , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1378-
1379- responses = response . GetAwaiter ( ) . GetResult ( ) ;
1380- }
1381- else
1382- {
1383- responses = currentServer . FindName ( dep . Name , includePrerelease : true , _type , out errRecord ) ;
1384- }
1355+ // See if the network call we're making is already cached, if not, call FindNameAsync() and cache results
1356+ string key = $ "{ dep . Name } |*|{ _type } ";
1357+ debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1358+ response = _cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindNameAsync ( dep . Name , includePrerelease : true , _type , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1359+
1360+ responses = response . GetAwaiter ( ) . GetResult ( ) ;
13851361
13861362 // Error handling and Convert to PSResource object
13871363 if ( errRecord != null )
@@ -1445,21 +1421,13 @@ private PSResourceInfo FindDependencyWithUpperBound(
14451421
14461422 ConcurrentDictionary < string , Task < FindResults > > cachedNetworkCalls = new ConcurrentDictionary < string , Task < FindResults > > ( ) ;
14471423 debugMsgs . Enqueue ( "In FindHelper::FindDependencyWithUpperBound()" ) ;
1424+ // See if the network call we're making is already caced, if not, call FindNameAsync() and cache results
1425+ string key = $ "{ dep . Name } |{ dep . VersionRange . MaxVersion . ToString ( ) } |{ _type } ";
1426+ debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1427+ response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionGlobbingAsync ( dep . Name , dep . VersionRange , includePrerelease : true , ResourceType . None , getOnlyLatest : true , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
14481428
1449- if ( currentServer . Repository . ApiVersion == PSRepositoryInfo . APIVersion . V2 )
1450- {
1451- // See if the network call we're making is already caced, if not, call FindNameAsync() and cache results
1452- string key = $ "{ dep . Name } |{ dep . VersionRange . MaxVersion . ToString ( ) } |{ _type } ";
1453- debugMsgs . Enqueue ( "Checking if network call is cached." ) ;
1454- response = cachedNetworkCalls . GetOrAdd ( key , _ => currentServer . FindVersionGlobbingAsync ( dep . Name , dep . VersionRange , includePrerelease : true , ResourceType . None , getOnlyLatest : true , errorMsgs , warningMsgs , debugMsgs , verboseMsgs ) ) ;
1455-
1456- responses = response . GetAwaiter ( ) . GetResult ( ) ;
1429+ responses = response . GetAwaiter ( ) . GetResult ( ) ;
14571430
1458- }
1459- else
1460- {
1461- responses = currentServer . FindVersionGlobbing ( dep . Name , dep . VersionRange , includePrerelease : true , ResourceType . None , getOnlyLatest : true , out errRecord ) ;
1462- }
14631431
14641432 // Error handling and Convert to PSResource object
14651433 if ( errRecord != null )
0 commit comments