From 1ff4ab24f80f2ba0cd11c83f2ee8906791f2ced1 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 21 Mar 2019 20:01:13 -0500 Subject: [PATCH] (GH-1774) log on failing repo When attempting packaging operations like install/upgrade and a repositories fails, log a warning and continue on. #612 implemented some of the fixes for ignoring failing repositories, but apparently that didn't apply when querying those repositories outside of the package manager that was implemented with #1397. --- .../services/NugetService.cs | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 52ebaf4fd0..f1b1493855 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -968,36 +968,43 @@ private IPackage find_package(string packageName, SemanticVersion version, Choco foreach (var packageRepository in aggregateRepository.Repositories.or_empty_list_if_null()) { - this.Log().Debug("Using '" + packageRepository.Source + "'."); - this.Log().Debug("- Supports prereleases? '" + packageRepository.SupportsPrereleasePackages + "'."); - this.Log().Debug("- Is ServiceBased? '" + (packageRepository is IServiceBasedRepository) + "'."); + try + { + this.Log().Debug("Using '" + packageRepository.Source + "'."); + this.Log().Debug("- Supports prereleases? '" + packageRepository.SupportsPrereleasePackages + "'."); + this.Log().Debug("- Is ServiceBased? '" + (packageRepository is IServiceBasedRepository) + "'."); - // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() - IQueryable combinedResults = packageRepository.GetPackages().Where(x => x.Id.ToLower() == packageName); + // search based on lower case id - similar to PackageRepositoryExtensions.FindPackagesByIdCore() + IQueryable combinedResults = packageRepository.GetPackages().Where(x => x.Id.ToLower() == packageName); - if (config.Prerelease && packageRepository.SupportsPrereleasePackages) - { - combinedResults = combinedResults.Where(p => p.IsAbsoluteLatestVersion); - } - else - { - combinedResults = combinedResults.Where(p => p.IsLatestVersion); - } + if (config.Prerelease && packageRepository.SupportsPrereleasePackages) + { + combinedResults = combinedResults.Where(p => p.IsAbsoluteLatestVersion); + } + else + { + combinedResults = combinedResults.Where(p => p.IsLatestVersion); + } - if (!(packageRepository is IServiceBasedRepository)) - { - combinedResults = combinedResults - .Where(PackageExtensions.IsListed) - .Where(p => config.Prerelease || p.IsReleaseVersion()) - .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) - .AsQueryable(); - } + if (!(packageRepository is IServiceBasedRepository)) + { + combinedResults = combinedResults + .Where(PackageExtensions.IsListed) + .Where(p => config.Prerelease || p.IsReleaseVersion()) + .distinct_last(PackageEqualityComparer.Id, PackageComparer.Version) + .AsQueryable(); + } - var packageRepositoryResults = combinedResults.ToList(); - if (packageRepositoryResults.Count() != 0) + var packageRepositoryResults = combinedResults.ToList(); + if (packageRepositoryResults.Count() != 0) + { + this.Log().Debug("Package '{0}' found on source '{1}'".format_with(packageName, packageRepository.Source)); + packageResults.AddRange(packageRepositoryResults); + } + } + catch (Exception e) { - this.Log().Debug("Package '{0}' found on source '{1}'".format_with(packageName, packageRepository.Source)); - packageResults.AddRange(packageRepositoryResults); + this.Log().Warn("Error retrieving packages from source '{0}':{1} {2}".format_with(packageRepository.Source, Environment.NewLine, e.Message)); } }