From dadfb8d008fb4f621cdb2b23efde0ddba0e51d59 Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Tue, 5 Aug 2025 10:26:27 +0100 Subject: [PATCH] Fixed: Saving Newznab indexer when redirect was true --- src/NzbDrone.Core/Indexers/IndexerBase.cs | 6 ------ .../Indexers/IndexerController.cs | 18 ++++++++++++++++++ src/Prowlarr.Api.V1/ProviderControllerBase.cs | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index 2f545e0cd..5a3b36bbe 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -208,12 +208,6 @@ namespace NzbDrone.Core.Indexers try { - // Ensure Redirect is true for Usenet protocols - if (Protocol == DownloadProtocol.Usenet || (SupportsRedirect && Redirect)) - { - failures.Add(new ValidationFailure("Redirect", "Redirect must be enabled for Usenet indexers")); - } - Test(failures).GetAwaiter().GetResult(); } catch (Exception ex) diff --git a/src/Prowlarr.Api.V1/Indexers/IndexerController.cs b/src/Prowlarr.Api.V1/Indexers/IndexerController.cs index 07955299d..fe47a60c9 100644 --- a/src/Prowlarr.Api.V1/Indexers/IndexerController.cs +++ b/src/Prowlarr.Api.V1/Indexers/IndexerController.cs @@ -1,4 +1,6 @@ +using System.Collections.Generic; using FluentValidation; +using FluentValidation.Results; using NzbDrone.Core.Indexers; using NzbDrone.Core.Validation; using NzbDrone.SignalR; @@ -24,5 +26,21 @@ namespace Prowlarr.Api.V1.Indexers SharedValidator.RuleFor(c => c.Priority).InclusiveBetween(1, 50); SharedValidator.RuleFor(c => c.DownloadClientId).SetValidator(downloadClientExistsValidator); } + + protected override void Validate(IndexerDefinition definition, bool includeWarnings) + { + var instance = _providerFactory.GetInstance(definition); + + // Ensure Redirect is true for Usenet protocols + if (instance is { Protocol: DownloadProtocol.Usenet, SupportsRedirect: true } && definition is { Redirect: false }) + { + throw new ValidationException(new List + { + new("Redirect", "Redirect must be enabled for Usenet indexers") + }); + } + + base.Validate(definition, includeWarnings); + } } } diff --git a/src/Prowlarr.Api.V1/ProviderControllerBase.cs b/src/Prowlarr.Api.V1/ProviderControllerBase.cs index 725f6e58b..92049f2dd 100644 --- a/src/Prowlarr.Api.V1/ProviderControllerBase.cs +++ b/src/Prowlarr.Api.V1/ProviderControllerBase.cs @@ -271,7 +271,7 @@ namespace Prowlarr.Api.V1 BroadcastResourceChange(ModelAction.Deleted, message.ProviderId); } - private void Validate(TProviderDefinition definition, bool includeWarnings) + protected virtual void Validate(TProviderDefinition definition, bool includeWarnings) { var validationResult = definition.Settings.Validate();