diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 7567d503b2..21912f20ac 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -137,6 +137,11 @@ public ChocolateyPackageService( public virtual int Count(ChocolateyConfiguration config) { + if (config.SourceType.IsEqualTo(SourceTypes.Normal)) + { + return _nugetService.Count(config); + } + return PerformSourceRunnerFunction( config, runner => runner.Count(config), @@ -153,7 +158,7 @@ private void PerformSourceRunnerAction(ChocolateyConfiguration co private void PerformSourceRunnerAction(ChocolateyConfiguration config, Action action, IEnumerable alternativeSourceRunners, bool throwOnException = false) where TSourceRunner : class, IAlternativeSourceRunner { - var runner = GetSourceRunner(config.SourceType, alternativeSourceRunners); + var runner = GetSourceRunner(config.SourceType, alternativeSourceRunners); if (runner != null && action != null) { if (runner is IBootstrappableSourceRunner bootstrapper) @@ -186,7 +191,7 @@ private TResult PerformSourceRunnerFunction(ChocolateyCo private TResult PerformSourceRunnerFunction(ChocolateyConfiguration config, Func function, IEnumerable alternativeSourceRunners, bool throwOnException = false) where TSourceRunner : class, IAlternativeSourceRunner { - var runner = GetSourceRunner(config.SourceType, alternativeSourceRunners); + var runner = GetSourceRunner(config.SourceType, alternativeSourceRunners); if (runner != null && function != null) { if (runner is IBootstrappableSourceRunner bootstrapper) @@ -209,7 +214,7 @@ private TResult PerformSourceRunnerFunction(ChocolateyCo this.Log().Warn("No runner was found that implements source type '{0}' or, it does not support requested functionality.".FormatWith(config.SourceType)); } - return default(TResult); + return default; } public void ListDryRun(ChocolateyConfiguration config) @@ -1795,15 +1800,6 @@ private void LogEnvironmentChanges(ChocolateyConfiguration config, IEnumerable(string sourceType) - where TSourceRunner : class, IAlternativeSourceRunner - { - // We add the trailing s to the check in case of windows feature which can be specified both with and without - // the s. - var sourceRunners = _containerResolver.ResolveAll(); - return GetSourceRunner(sourceType, sourceRunners); - } - private TSourceRunner GetSourceRunner(string sourceType, IEnumerable alternativeSourceRunners) where TSourceRunner : class, IAlternativeSourceRunner {