diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerDownloadClientCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerDownloadClientCheck.cs new file mode 100644 index 000000000..94592426e --- /dev/null +++ b/src/NzbDrone.Core/HealthCheck/Checks/IndexerDownloadClientCheck.cs @@ -0,0 +1,45 @@ +using System.Linq; +using NzbDrone.Core.Download; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Localization; +using NzbDrone.Core.ThingiProvider.Events; + +namespace NzbDrone.Core.HealthCheck.Checks +{ + [CheckOn(typeof(ProviderUpdatedEvent))] + [CheckOn(typeof(ProviderDeletedEvent))] + [CheckOn(typeof(ProviderUpdatedEvent))] + [CheckOn(typeof(ProviderDeletedEvent))] + public class IndexerDownloadClientCheck : HealthCheckBase + { + private readonly IIndexerFactory _indexerFactory; + private readonly IDownloadClientFactory _downloadClientFactory; + + public IndexerDownloadClientCheck(IIndexerFactory indexerFactory, + IDownloadClientFactory downloadClientFactory, + ILocalizationService localizationService) + : base(localizationService) + { + _indexerFactory = indexerFactory; + _downloadClientFactory = downloadClientFactory; + } + + public override HealthCheck Check() + { + var downloadClientsIds = _downloadClientFactory.All().Where(v => v.Enable).Select(v => v.Id).ToList(); + var invalidIndexers = _indexerFactory.All() + .Where(v => v.Enable && v.DownloadClientId > 0 && !downloadClientsIds.Contains(v.DownloadClientId)) + .ToList(); + + if (invalidIndexers.Any()) + { + return new HealthCheck(GetType(), + HealthCheckResult.Warning, + string.Format(_localizationService.GetLocalizedString("IndexerDownloadClientHealthCheckMessage"), string.Join(", ", invalidIndexers.Select(v => v.Name).ToArray())), + "#invalid-indexer-download-client-setting"); + } + + return new HealthCheck(GetType()); + } + } +} diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index b28e1b6e9..6f3bb3f40 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -471,6 +471,7 @@ "IncludeUnknownMovieItemsHelpText": "Show items without a movie in the queue. This could include removed movies or anything else in Radarr's category", "IncludeUnmonitored": "Include Unmonitored", "Indexer": "Indexer", + "IndexerDownloadClientHealthCheckMessage": "Indexers with invalid download clients: {0}.", "IndexerDownloadClientHelpText": "Specify which download client is used for grabs from this indexer", "IndexerFlags": "Indexer Flags", "IndexerJackettAll": "Indexers using the unsupported Jackett 'all' endpoint: {0}",