From a08b9e4f64adf3d47f6526d7cc2627b0f0416352 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 29 Jul 2023 05:09:06 +0300 Subject: [PATCH] Fixed: Ensure failing indexers are marked as failed when testing all (cherry picked from commit b407eba61284d5fb855df6a2868805853aa6f448) Closes #3934 --- src/NzbDrone.Core/Indexers/IndexerFactory.cs | 11 +++++++- src/NzbDrone.Core/Indexers/Newznab/Newznab.cs | 25 +++++++++++++----- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 26 ++++++++++++++----- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/IndexerFactory.cs b/src/NzbDrone.Core/Indexers/IndexerFactory.cs index 58f3a3f68..d26ed6b56 100644 --- a/src/NzbDrone.Core/Indexers/IndexerFactory.cs +++ b/src/NzbDrone.Core/Indexers/IndexerFactory.cs @@ -102,10 +102,19 @@ namespace NzbDrone.Core.Indexers { var result = base.Test(definition); - if ((result == null || result.IsValid) && definition.Id != 0) + if (definition.Id == 0) + { + return result; + } + + if (result == null || result.IsValid) { _indexerStatusService.RecordSuccess(definition.Id); } + else + { + _indexerStatusService.RecordFailure(definition.Id); + } return result; } diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index eea150fa5..3d65d68d4 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -19,8 +19,13 @@ namespace NzbDrone.Core.Indexers.Newznab public override string Name => "Newznab"; public override DownloadProtocol Protocol => DownloadProtocol.Usenet; + public override int PageSize => GetProviderPageSize(); - public override int PageSize => Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize)); + public Newznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) + : base(httpClient, indexerStatusService, configService, parsingService, logger) + { + _capabilitiesProvider = capabilitiesProvider; + } public override IIndexerRequestGenerator GetRequestGenerator() { @@ -54,12 +59,6 @@ namespace NzbDrone.Core.Indexers.Newznab } } - public Newznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) - : base(httpClient, indexerStatusService, configService, parsingService, logger) - { - _capabilitiesProvider = capabilitiesProvider; - } - private IndexerDefinition GetDefinition(string name, NewznabSettings settings) { return new IndexerDefinition @@ -163,5 +162,17 @@ namespace NzbDrone.Core.Indexers.Newznab return base.RequestAction(action, query); } + + private int GetProviderPageSize() + { + try + { + return Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize)); + } + catch + { + return 100; + } + } } } diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index 65543b9b1..b09e25627 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -19,7 +19,13 @@ namespace NzbDrone.Core.Indexers.Torznab public override string Name => "Torznab"; public override DownloadProtocol Protocol => DownloadProtocol.Torrent; - public override int PageSize => Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize)); + public override int PageSize => GetProviderPageSize(); + + public Torznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) + : base(httpClient, indexerStatusService, configService, parsingService, logger) + { + _capabilitiesProvider = capabilitiesProvider; + } public override IIndexerRequestGenerator GetRequestGenerator() { @@ -35,12 +41,6 @@ namespace NzbDrone.Core.Indexers.Torznab return new TorznabRssParser(); } - public Torznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) - : base(httpClient, indexerStatusService, configService, parsingService, logger) - { - _capabilitiesProvider = capabilitiesProvider; - } - private IndexerDefinition GetDefinition(string name, TorznabSettings settings) { return new IndexerDefinition @@ -147,5 +147,17 @@ namespace NzbDrone.Core.Indexers.Torznab return base.RequestAction(action, query); } + + private int GetProviderPageSize() + { + try + { + return Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize)); + } + catch + { + return 100; + } + } } }