From 9787cf6cdd397287150f1cc3227a3ff6f6d08095 Mon Sep 17 00:00:00 2001 From: Mitchell Cash Date: Sun, 5 Mar 2017 17:50:45 +1000 Subject: [PATCH] Improve indexer health check messages (#1015) * Improve indexer health check messages Fixed: Improve health check message when all enabled indexers are disabled due to failures Closes #1551 * Fixed: Health check failing and preventing others from running * Fixed Indexer Health Checks and tests. --- ...ase64Extentions.cs => Base64Extensions.cs} | 4 +- .../{XmlExtentions.cs => XmlExtensions.cs} | 4 +- src/NzbDrone.Common/NzbDrone.Common.csproj | 4 +- ...ons.cs => HealthCheckFixtureExtensions.cs} | 15 ++- .../Checks/IndexerRssCheckFixture.cs | 92 +++++++++++++++++++ ...ixture.cs => IndexerSearchCheckFixture.cs} | 81 +++++----------- .../NzbSearchServiceFixture.cs | 2 +- .../NzbDrone.Core.Test.csproj | 5 +- .../Checks/ImportMechanismCheck.cs | 41 +++++++-- .../HealthCheck/Checks/IndexerCheck.cs | 50 ---------- .../HealthCheck/Checks/IndexerRssCheck.cs | 35 +++++++ .../HealthCheck/Checks/IndexerSearchCheck.cs | 35 +++++++ src/NzbDrone.Core/Indexers/IndexerFactory.cs | 24 +++-- .../Indexers/XElementExtensions.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 3 +- 15 files changed, 260 insertions(+), 137 deletions(-) rename src/NzbDrone.Common/Extensions/{Base64Extentions.cs => Base64Extensions.cs} (88%) rename src/NzbDrone.Common/Extensions/{XmlExtentions.cs => XmlExtensions.cs} (91%) rename src/NzbDrone.Core.Test/HealthCheck/Checks/{HealthCheckFixtureExtentions.cs => HealthCheckFixtureExtensions.cs} (61%) create mode 100644 src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerRssCheckFixture.cs rename src/NzbDrone.Core.Test/HealthCheck/Checks/{IndexerCheckFixture.cs => IndexerSearchCheckFixture.cs} (50%) delete mode 100644 src/NzbDrone.Core/HealthCheck/Checks/IndexerCheck.cs create mode 100644 src/NzbDrone.Core/HealthCheck/Checks/IndexerRssCheck.cs create mode 100644 src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs diff --git a/src/NzbDrone.Common/Extensions/Base64Extentions.cs b/src/NzbDrone.Common/Extensions/Base64Extensions.cs similarity index 88% rename from src/NzbDrone.Common/Extensions/Base64Extentions.cs rename to src/NzbDrone.Common/Extensions/Base64Extensions.cs index 3a2dbcf3f..1d65ac298 100644 --- a/src/NzbDrone.Common/Extensions/Base64Extentions.cs +++ b/src/NzbDrone.Common/Extensions/Base64Extensions.cs @@ -2,7 +2,7 @@ using System; namespace NzbDrone.Common.Extensions { - public static class Base64Extentions + public static class Base64Extensions { public static string ToBase64(this byte[] bytes) { @@ -14,4 +14,4 @@ namespace NzbDrone.Common.Extensions return BitConverter.GetBytes(input).ToBase64(); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Common/Extensions/XmlExtentions.cs b/src/NzbDrone.Common/Extensions/XmlExtensions.cs similarity index 91% rename from src/NzbDrone.Common/Extensions/XmlExtentions.cs rename to src/NzbDrone.Common/Extensions/XmlExtensions.cs index 5e9ffd6db..84b163165 100644 --- a/src/NzbDrone.Common/Extensions/XmlExtentions.cs +++ b/src/NzbDrone.Common/Extensions/XmlExtensions.cs @@ -5,11 +5,11 @@ using System.Xml.Linq; namespace NzbDrone.Common.Extensions { - public static class XmlExtentions + public static class XmlExtensions { public static IEnumerable FindDecendants(this XContainer container, string localName) { return container.Descendants().Where(c => c.Name.LocalName.Equals(localName, StringComparison.InvariantCultureIgnoreCase)); } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 0b7d15c04..8d2d3da96 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -145,14 +145,14 @@ - + - + diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtentions.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtensions.cs similarity index 61% rename from src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtentions.cs rename to src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtensions.cs index fa1577974..5654fa388 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtentions.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/HealthCheckFixtureExtensions.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using NzbDrone.Common.Extensions; using NzbDrone.Core.HealthCheck; namespace NzbDrone.Core.Test.HealthCheck.Checks @@ -10,14 +11,24 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks result.Type.Should().Be(HealthCheckResult.Ok); } - public static void ShouldBeWarning(this Core.HealthCheck.HealthCheck result) + public static void ShouldBeWarning(this Core.HealthCheck.HealthCheck result, string message = null) { result.Type.Should().Be(HealthCheckResult.Warning); + + if (message.IsNotNullOrWhiteSpace()) + { + result.Message.Should().Contain(message); + } } - public static void ShouldBeError(this Core.HealthCheck.HealthCheck result) + public static void ShouldBeError(this Core.HealthCheck.HealthCheck result, string message = null) { result.Type.Should().Be(HealthCheckResult.Error); + + if (message.IsNotNullOrWhiteSpace()) + { + result.Message.Should().Contain(message); + } } } } diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerRssCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerRssCheckFixture.cs new file mode 100644 index 000000000..28d314005 --- /dev/null +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerRssCheckFixture.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.HealthCheck.Checks; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.HealthCheck.Checks +{ + [TestFixture] + public class IndexerRssCheckFixture : CoreTest + { + private Mock _indexerMock; + + [SetUp] + public void SetUp() + { + Mocker.GetMock() + .Setup(s => s.GetAvailableProviders()) + .Returns(new List()); + + Mocker.GetMock() + .Setup(s => s.RssEnabled(It.IsAny())) + .Returns(new List()); + } + + private void GivenIndexer(bool supportsRss, bool supportsSearch) + { + _indexerMock = Mocker.GetMock(); + _indexerMock.SetupGet(s => s.SupportsRss).Returns(supportsRss); + _indexerMock.SetupGet(s => s.SupportsSearch).Returns(supportsSearch); + + Mocker.GetMock() + .Setup(s => s.GetAvailableProviders()) + .Returns(new List { _indexerMock.Object }); + } + + private void GivenRssEnabled() + { + Mocker.GetMock() + .Setup(s => s.RssEnabled(It.IsAny())) + .Returns(new List { _indexerMock.Object }); + } + + private void GivenRssFiltered() + { + Mocker.GetMock() + .Setup(s => s.RssEnabled(false)) + .Returns(new List { _indexerMock.Object }); + } + + [Test] + public void should_return_error_when_no_indexer_present() + { + Subject.Check().ShouldBeError(); + } + + [Test] + public void should_return_error_when_no_rss_supported_indexer_present() + { + GivenIndexer(false, true); + + Subject.Check().ShouldBeError(); + } + + [Test] + public void should_return_ok_when_rss_is_enabled() + { + GivenIndexer(true, false); + GivenRssEnabled(); + + Subject.Check().ShouldBeOk(); + } + + [Test] + public void should_return_error_if_rss_is_supported_but_disabled() + { + GivenIndexer(true, false); + + Subject.Check().ShouldBeError(); + } + + [Test] + public void should_return_filter_warning_if_rss_is_enabled_but_filtered() + { + GivenIndexer(true, false); + GivenRssFiltered(); + + Subject.Check().ShouldBeWarning("recent indexer errors"); + } + } +} diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs similarity index 50% rename from src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerCheckFixture.cs rename to src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs index 513784d27..8cbc28b9d 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs @@ -8,116 +8,85 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.HealthCheck.Checks { [TestFixture] - public class IndexerCheckFixture : CoreTest + public class IndexerSearchCheckFixture : CoreTest { private Mock _indexerMock; - private void GivenIndexer(bool supportsRss, bool supportsSearch) + [SetUp] + public void SetUp() { - _indexerMock = Mocker.GetMock(); - _indexerMock.SetupGet(s => s.SupportsRss).Returns(supportsRss); - _indexerMock.SetupGet(s => s.SupportsSearch).Returns(supportsSearch); - Mocker.GetMock() .Setup(s => s.GetAvailableProviders()) - .Returns(new List { _indexerMock.Object }); - - Mocker.GetMock() - .Setup(s => s.RssEnabled()) .Returns(new List()); Mocker.GetMock() - .Setup(s => s.SearchEnabled()) + .Setup(s => s.SearchEnabled(It.IsAny())) .Returns(new List()); } - private void GivenRssEnabled() + private void GivenIndexer(bool supportsRss, bool supportsSearch) { + _indexerMock = Mocker.GetMock(); + _indexerMock.SetupGet(s => s.SupportsRss).Returns(supportsRss); + _indexerMock.SetupGet(s => s.SupportsSearch).Returns(supportsSearch); + Mocker.GetMock() - .Setup(s => s.RssEnabled()) + .Setup(s => s.GetAvailableProviders()) .Returns(new List { _indexerMock.Object }); } private void GivenSearchEnabled() { Mocker.GetMock() - .Setup(s => s.SearchEnabled()) + .Setup(s => s.SearchEnabled(It.IsAny())) .Returns(new List { _indexerMock.Object }); } - [Test] - public void should_return_error_when_not_indexers_are_enabled() + private void GivenSearchFiltered() { Mocker.GetMock() - .Setup(s => s.GetAvailableProviders()) - .Returns(new List()); - - Subject.Check().ShouldBeError(); + .Setup(s => s.SearchEnabled(false)) + .Returns(new List { _indexerMock.Object }); } [Test] - public void should_return_warning_when_only_enabled_indexer_doesnt_support_search() + public void should_return_warning_when_no_indexer_present() { - GivenIndexer(true, false); - Subject.Check().ShouldBeWarning(); } [Test] - public void should_return_warning_when_only_enabled_indexer_doesnt_support_rss() + public void should_return_warning_when_no_search_supported_indexer_present() { - GivenIndexer(false, true); + GivenIndexer(true, false); Subject.Check().ShouldBeWarning(); } [Test] - public void should_return_ok_when_multiple_indexers_are_enabled() + public void should_return_ok_when_search_is_enabled() { - GivenRssEnabled(); - GivenSearchEnabled(); - - var indexer1 = Mocker.GetMock(); - indexer1.SetupGet(s => s.SupportsRss).Returns(true); - indexer1.SetupGet(s => s.SupportsSearch).Returns(true); - - var indexer2 = new Moq.Mock(); - indexer2.SetupGet(s => s.SupportsRss).Returns(true); - indexer2.SetupGet(s => s.SupportsSearch).Returns(false); - - Mocker.GetMock() - .Setup(s => s.GetAvailableProviders()) - .Returns(new List { indexer1.Object, indexer2.Object }); - - Subject.Check().ShouldBeOk(); - } - - [Test] - public void should_return_ok_when_indexer_supports_rss_and_search() - { - GivenIndexer(true, true); - GivenRssEnabled(); + GivenIndexer(false, true); GivenSearchEnabled(); Subject.Check().ShouldBeOk(); } [Test] - public void should_return_warning_if_rss_is_supported_but_disabled() + public void should_return_warning_if_search_is_supported_but_disabled() { - GivenIndexer(true, true); - GivenSearchEnabled(); + GivenIndexer(false, true); Subject.Check().ShouldBeWarning(); } [Test] - public void should_return_warning_if_search_is_supported_but_disabled() + public void should_return_filter_warning_if_search_is_enabled_but_filtered() { - GivenIndexer(true, true); - GivenRssEnabled(); + GivenIndexer(false, true); + GivenSearchFiltered(); - Subject.Check().ShouldBeWarning(); + Subject.Check().ShouldBeWarning("recent indexer errors"); } } } diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs index 9b01ad829..f6089004e 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/NzbSearchServiceFixture.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests _mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true); Mocker.GetMock() - .Setup(s => s.SearchEnabled()) + .Setup(s => s.SearchEnabled(true)) .Returns(new List { _mockIndexer.Object }); Mocker.GetMock() diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 09a2cd07a..54cc53118 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -214,9 +214,10 @@ - + - + + diff --git a/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs index 373d47bfb..ec35653c7 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/ImportMechanismCheck.cs @@ -1,7 +1,10 @@ -using System.Linq; +using System; +using System.Collections.Generic; +using System.Linq; using NzbDrone.Common.Disk; using NzbDrone.Core.Configuration; using NzbDrone.Core.Download; +using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Sabnzbd; @@ -22,11 +25,26 @@ namespace NzbDrone.Core.HealthCheck.Checks public override HealthCheck Check() { var droneFactoryFolder = new OsPath(_configService.DownloadedEpisodesFolder); - var downloadClients = _provideDownloadClient.GetDownloadClients().Select(v => new { downloadClient = v, status = v.GetStatus() }).ToList(); + List downloadClients; - var downloadClientIsLocalHost = downloadClients.All(v => v.status.IsLocalhost); - var downloadClientOutputInDroneFactory = !droneFactoryFolder.IsEmpty - && downloadClients.Any(v => v.status.OutputRootFolders != null && v.status.OutputRootFolders.Any(droneFactoryFolder.Contains)); + try + { + downloadClients = _provideDownloadClient.GetDownloadClients().Select(v => new ImportMechanismCheckStatus + { + DownloadClient = v, + Status = v.GetStatus() + }).ToList(); + } + catch (DownloadClientException) + { + // One or more download clients failed, assume the health is okay and verify later + return new HealthCheck(GetType()); + } + + var downloadClientIsLocalHost = downloadClients.All(v => v.Status.IsLocalhost); + var downloadClientOutputInDroneFactory = !droneFactoryFolder.IsEmpty && + downloadClients.Any(v => v.Status.OutputRootFolders != null && + v.Status.OutputRootFolders.Any(droneFactoryFolder.Contains)); if (!_configService.IsDefined("EnableCompletedDownloadHandling")) { @@ -36,7 +54,7 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Multi-Computer unsupported)", "Migrating-to-Completed-Download-Handling#Unsupported-download-client-on-different-computer"); } - if (downloadClients.All(v => v.downloadClient is Sabnzbd)) + if (downloadClients.All(v => v.DownloadClient is Sabnzbd)) { // With Sabnzbd we can check if the category should be changed. if (downloadClientOutputInDroneFactory) @@ -46,7 +64,8 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "Migrating-to-Completed-Download-Handling#sabnzbd-enable-completed-download-handling"); } - if (downloadClients.All(v => v.downloadClient is Nzbget)) + + if (downloadClients.All(v => v.DownloadClient is Nzbget)) { // With Nzbget we can check if the category should be changed. if (downloadClientOutputInDroneFactory) @@ -56,6 +75,7 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "Migrating-to-Completed-Download-Handling#nzbget-enable-completed-download-handling"); } + return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling"); } @@ -64,8 +84,13 @@ namespace NzbDrone.Core.HealthCheck.Checks return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling or configure Drone factory"); } - return new HealthCheck(GetType()); } } + + public class ImportMechanismCheckStatus + { + public IDownloadClient DownloadClient { get; set; } + public DownloadClientStatus Status { get; set; } + } } diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerCheck.cs deleted file mode 100644 index 88347b690..000000000 --- a/src/NzbDrone.Core/HealthCheck/Checks/IndexerCheck.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Indexers; - -namespace NzbDrone.Core.HealthCheck.Checks -{ - public class IndexerCheck : HealthCheckBase - { - private readonly IIndexerFactory _indexerFactory; - - public IndexerCheck(IIndexerFactory indexerFactory) - { - _indexerFactory = indexerFactory; - } - - public override HealthCheck Check() - { - var enabled = _indexerFactory.GetAvailableProviders(); - var rssEnabled = _indexerFactory.RssEnabled(); - var searchEnabled = _indexerFactory.SearchEnabled(); - - if (enabled.Empty()) - { - return new HealthCheck(GetType(), HealthCheckResult.Error, "No indexers are enabled"); - } - - if (enabled.All(i => i.SupportsRss == false)) - { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not support RSS sync"); - } - - if (enabled.All(i => i.SupportsSearch == false)) - { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not support searching"); - } - - if (rssEnabled.Empty()) - { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have RSS sync enabled"); - } - - if (searchEnabled.Empty()) - { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enabled indexers do not have searching enabled"); - } - - return new HealthCheck(GetType()); - } - } -} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerRssCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerRssCheck.cs new file mode 100644 index 000000000..e0c9c9e5c --- /dev/null +++ b/src/NzbDrone.Core/HealthCheck/Checks/IndexerRssCheck.cs @@ -0,0 +1,35 @@ +using System.Linq; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Indexers; + +namespace NzbDrone.Core.HealthCheck.Checks +{ + public class IndexerRssCheck : HealthCheckBase + { + private readonly IIndexerFactory _indexerFactory; + + public IndexerRssCheck(IIndexerFactory indexerFactory) + { + _indexerFactory = indexerFactory; + } + + public override HealthCheck Check() + { + var enabled = _indexerFactory.RssEnabled(false); + + if (enabled.Empty()) + { + return new HealthCheck(GetType(), HealthCheckResult.Error, "No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically"); + } + + var active = _indexerFactory.RssEnabled(true); + + if (active.Empty()) + { + return new HealthCheck(GetType(), HealthCheckResult.Warning, "All rss-capable indexers are temporarily unavailable due to recent indexer errors"); + } + + return new HealthCheck(GetType()); + } + } +} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs new file mode 100644 index 000000000..b2b81e4ec --- /dev/null +++ b/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs @@ -0,0 +1,35 @@ +using System.Linq; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Indexers; + +namespace NzbDrone.Core.HealthCheck.Checks +{ + public class IndexerSearchCheck : HealthCheckBase + { + private readonly IIndexerFactory _indexerFactory; + + public IndexerSearchCheck(IIndexerFactory indexerFactory) + { + _indexerFactory = indexerFactory; + } + + public override HealthCheck Check() + { + var enabled = _indexerFactory.SearchEnabled(false); + + if (enabled.Empty()) + { + return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Search enabled, Sonarr will not provide any search results"); + } + + var active = _indexerFactory.SearchEnabled(true); + + if (active.Empty()) + { + return new HealthCheck(GetType(), HealthCheckResult.Warning, "All search-capable indexers are temporarily unavailable due to recent indexer errors"); + } + + return new HealthCheck(GetType()); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/IndexerFactory.cs b/src/NzbDrone.Core/Indexers/IndexerFactory.cs index 8e45a031c..c4903c9c7 100644 --- a/src/NzbDrone.Core/Indexers/IndexerFactory.cs +++ b/src/NzbDrone.Core/Indexers/IndexerFactory.cs @@ -9,14 +9,13 @@ namespace NzbDrone.Core.Indexers { public interface IIndexerFactory : IProviderFactory { - List RssEnabled(); - List SearchEnabled(); + List RssEnabled(bool filterBlockedIndexers = true); + List SearchEnabled(bool filterBlockedIndexers = true); } public class IndexerFactory : ProviderFactory, IIndexerFactory { private readonly IIndexerStatusService _indexerStatusService; - private readonly IIndexerRepository _providerRepository; private readonly Logger _logger; public IndexerFactory(IIndexerStatusService indexerStatusService, @@ -28,7 +27,6 @@ namespace NzbDrone.Core.Indexers : base(providerRepository, providers, container, eventAggregator, logger) { _indexerStatusService = indexerStatusService; - _providerRepository = providerRepository; _logger = logger; } @@ -46,22 +44,28 @@ namespace NzbDrone.Core.Indexers definition.SupportsSearch = provider.SupportsSearch; } - public List RssEnabled() + public List RssEnabled(bool filterBlockedIndexers = true) { var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableRss); - var indexers = FilterBlockedIndexers(enabledIndexers); + if (filterBlockedIndexers) + { + return FilterBlockedIndexers(enabledIndexers).ToList(); + } - return indexers.ToList(); + return enabledIndexers.ToList(); } - public List SearchEnabled() + public List SearchEnabled(bool filterBlockedIndexers = true) { var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableSearch); - var indexers = FilterBlockedIndexers(enabledIndexers); + if (filterBlockedIndexers) + { + return FilterBlockedIndexers(enabledIndexers).ToList(); + } - return indexers.ToList(); + return enabledIndexers.ToList(); } private IEnumerable FilterBlockedIndexers(IEnumerable indexers) diff --git a/src/NzbDrone.Core/Indexers/XElementExtensions.cs b/src/NzbDrone.Core/Indexers/XElementExtensions.cs index 72da2790d..ef2b8b064 100644 --- a/src/NzbDrone.Core/Indexers/XElementExtensions.cs +++ b/src/NzbDrone.Core/Indexers/XElementExtensions.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Indexers { public static class XElementExtensions { - private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(XmlExtentions)); + private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(XmlExtensions)); public static readonly Regex RemoveTimeZoneRegex = new Regex(@"\s[A-Z]{2,4}$", RegexOptions.Compiled); diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 314608246..721130fdb 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -615,8 +615,9 @@ + - +