mirror of https://github.com/Radarr/Radarr
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.
This commit is contained in:
parent
7433e89467
commit
9787cf6cdd
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@ using System.Xml.Linq;
|
|||
|
||||
namespace NzbDrone.Common.Extensions
|
||||
{
|
||||
public static class XmlExtentions
|
||||
public static class XmlExtensions
|
||||
{
|
||||
public static IEnumerable<XElement> FindDecendants(this XContainer container, string localName)
|
||||
{
|
||||
return container.Descendants().Where(c => c.Name.LocalName.Equals(localName, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -145,14 +145,14 @@
|
|||
<Compile Include="Expansive\Tree.cs" />
|
||||
<Compile Include="Expansive\TreeNode.cs" />
|
||||
<Compile Include="Expansive\TreeNodeList.cs" />
|
||||
<Compile Include="Extensions\Base64Extentions.cs" />
|
||||
<Compile Include="Extensions\Base64Extensions.cs" />
|
||||
<Compile Include="Extensions\DateTimeExtensions.cs" />
|
||||
<Compile Include="Crypto\HashConverter.cs" />
|
||||
<Compile Include="Extensions\Int64Extensions.cs" />
|
||||
<Compile Include="Extensions\ObjectExtensions.cs" />
|
||||
<Compile Include="Extensions\StreamExtensions.cs" />
|
||||
<Compile Include="Extensions\UrlExtensions.cs" />
|
||||
<Compile Include="Extensions\XmlExtentions.cs" />
|
||||
<Compile Include="Extensions\XmlExtensions.cs" />
|
||||
<Compile Include="HashUtil.cs" />
|
||||
<Compile Include="Http\Dispatchers\CurlHttpDispatcher.cs" />
|
||||
<Compile Include="Http\Dispatchers\FallbackHttpDispatcher.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<IndexerRssCheck>
|
||||
{
|
||||
private Mock<IIndexer> _indexerMock;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer>());
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled(It.IsAny<bool>()))
|
||||
.Returns(new List<IIndexer>());
|
||||
}
|
||||
|
||||
private void GivenIndexer(bool supportsRss, bool supportsSearch)
|
||||
{
|
||||
_indexerMock = Mocker.GetMock<IIndexer>();
|
||||
_indexerMock.SetupGet(s => s.SupportsRss).Returns(supportsRss);
|
||||
_indexerMock.SetupGet(s => s.SupportsSearch).Returns(supportsSearch);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
private void GivenRssEnabled()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled(It.IsAny<bool>()))
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
private void GivenRssFiltered()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled(false))
|
||||
.Returns(new List<IIndexer> { _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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,10 +8,22 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class IndexerCheckFixture : CoreTest<IndexerCheck>
|
||||
public class IndexerSearchCheckFixture : CoreTest<IndexerSearchCheck>
|
||||
{
|
||||
private Mock<IIndexer> _indexerMock;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer>());
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled(It.IsAny<bool>()))
|
||||
.Returns(new List<IIndexer>());
|
||||
}
|
||||
|
||||
private void GivenIndexer(bool supportsRss, bool supportsSearch)
|
||||
{
|
||||
_indexerMock = Mocker.GetMock<IIndexer>();
|
||||
|
@ -21,42 +33,30 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled())
|
||||
.Returns(new List<IIndexer>());
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Returns(new List<IIndexer>());
|
||||
}
|
||||
|
||||
private void GivenRssEnabled()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.RssEnabled())
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
private void GivenSearchEnabled()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Setup(s => s.SearchEnabled(It.IsAny<bool>()))
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
private void GivenSearchFiltered()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled(false))
|
||||
.Returns(new List<IIndexer> { _indexerMock.Object });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_error_when_not_indexers_are_enabled()
|
||||
public void should_return_warning_when_no_indexer_present()
|
||||
{
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer>());
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_only_enabled_indexer_doesnt_support_search()
|
||||
public void should_return_warning_when_no_search_supported_indexer_present()
|
||||
{
|
||||
GivenIndexer(true, false);
|
||||
|
||||
|
@ -64,7 +64,16 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_only_enabled_indexer_doesnt_support_rss()
|
||||
public void should_return_ok_when_search_is_enabled()
|
||||
{
|
||||
GivenIndexer(false, true);
|
||||
GivenSearchEnabled();
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_if_search_is_supported_but_disabled()
|
||||
{
|
||||
GivenIndexer(false, true);
|
||||
|
||||
|
@ -72,52 +81,12 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_multiple_indexers_are_enabled()
|
||||
public void should_return_filter_warning_if_search_is_enabled_but_filtered()
|
||||
{
|
||||
GivenRssEnabled();
|
||||
GivenSearchEnabled();
|
||||
GivenIndexer(false, true);
|
||||
GivenSearchFiltered();
|
||||
|
||||
var indexer1 = Mocker.GetMock<IIndexer>();
|
||||
indexer1.SetupGet(s => s.SupportsRss).Returns(true);
|
||||
indexer1.SetupGet(s => s.SupportsSearch).Returns(true);
|
||||
|
||||
var indexer2 = new Moq.Mock<IIndexer>();
|
||||
indexer2.SetupGet(s => s.SupportsRss).Returns(true);
|
||||
indexer2.SetupGet(s => s.SupportsSearch).Returns(false);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.GetAvailableProviders())
|
||||
.Returns(new List<IIndexer> { indexer1.Object, indexer2.Object });
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_when_indexer_supports_rss_and_search()
|
||||
{
|
||||
GivenIndexer(true, true);
|
||||
GivenRssEnabled();
|
||||
GivenSearchEnabled();
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_if_rss_is_supported_but_disabled()
|
||||
{
|
||||
GivenIndexer(true, true);
|
||||
GivenSearchEnabled();
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_if_search_is_supported_but_disabled()
|
||||
{
|
||||
GivenIndexer(true, true);
|
||||
GivenRssEnabled();
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
Subject.Check().ShouldBeWarning("recent indexer errors");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests
|
|||
_mockIndexer.SetupGet(s => s.SupportsSearch).Returns(true);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(s => s.SearchEnabled())
|
||||
.Setup(s => s.SearchEnabled(true))
|
||||
.Returns(new List<IIndexer> { _mockIndexer.Object });
|
||||
|
||||
Mocker.GetMock<IMakeDownloadDecision>()
|
||||
|
|
|
@ -214,9 +214,10 @@
|
|||
<Compile Include="HealthCheck\Checks\AppDataLocationFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\HealthCheckFixtureExtentions.cs" />
|
||||
<Compile Include="HealthCheck\Checks\HealthCheckFixtureExtensions.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerSearchCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerRssCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerStatusCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\RootFolderCheckFixture.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<ImportMechanismCheckStatus> 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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,14 +9,13 @@ namespace NzbDrone.Core.Indexers
|
|||
{
|
||||
public interface IIndexerFactory : IProviderFactory<IIndexer, IndexerDefinition>
|
||||
{
|
||||
List<IIndexer> RssEnabled();
|
||||
List<IIndexer> SearchEnabled();
|
||||
List<IIndexer> RssEnabled(bool filterBlockedIndexers = true);
|
||||
List<IIndexer> SearchEnabled(bool filterBlockedIndexers = true);
|
||||
}
|
||||
|
||||
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, 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<IIndexer> RssEnabled()
|
||||
public List<IIndexer> 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<IIndexer> SearchEnabled()
|
||||
public List<IIndexer> 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<IIndexer> FilterBlockedIndexers(IEnumerable<IIndexer> indexers)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -615,8 +615,9 @@
|
|||
<Compile Include="HealthCheck\Checks\DownloadClientCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ImportMechanismCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerRssCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerStatusCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerSearchCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MediaInfoDllCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\ProxyCheck.cs" />
|
||||
|
|
Loading…
Reference in New Issue