From eb2e7b9c79f7c91b3deb185f7f5ae0ced79f2122 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 24 Mar 2019 15:22:50 +0100 Subject: [PATCH] Continue Test in case of validation warnings. --- .../Download/Clients/Deluge/Deluge.cs | 2 +- .../DownloadStation/TorrentDownloadStation.cs | 2 +- .../DownloadStation/UsenetDownloadStation.cs | 2 +- .../Download/Clients/Hadouken/Hadouken.cs | 2 +- .../Clients/QBittorrent/QBittorrent.cs | 2 +- .../Clients/Transmission/TransmissionBase.cs | 2 +- .../Download/Clients/rTorrent/RTorrent.cs | 2 +- .../Download/Clients/uTorrent/UTorrent.cs | 2 +- src/NzbDrone.Core/Indexers/Newznab/Newznab.cs | 3 ++- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 3 ++- .../Validation/NzbDroneValidationExtensions.cs | 18 ++++++++++++++++++ 11 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 038ffbacf..7a55bedc8 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -198,7 +198,7 @@ public override DownloadClientInfo GetStatus() protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestCategory()); failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index a272e5560..15508af90 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -194,7 +194,7 @@ protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestOutputPath()); failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 2e6cf3d08..fda9c339d 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -189,7 +189,7 @@ protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string fil protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestOutputPath()); failures.AddIfNotNull(TestGetNZB()); } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index 1c2d660da..41473fa33 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -130,7 +130,7 @@ public override DownloadClientInfo GetStatus() protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index ee1291554..645acf386 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -215,7 +215,7 @@ public override DownloadClientInfo GetStatus() protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestPrioritySupport()); failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index dd4d8eea4..e583edaa7 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -165,7 +165,7 @@ protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index 535bcd588..7ff02b331 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -163,7 +163,7 @@ public override DownloadClientInfo GetStatus() protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestGetTorrents()); failures.AddIfNotNull(TestDirectory()); } diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 40da8f483..664c9ba36 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -224,7 +224,7 @@ public override DownloadClientInfo GetStatus() protected override void Test(List failures) { failures.AddIfNotNull(TestConnection()); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestGetTorrents()); } diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 79c40b997..33bd3936e 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -8,6 +8,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Newznab { @@ -102,7 +103,7 @@ private NewznabSettings GetSettings(string url, string apiPath = null, int[] cat protected override void Test(List failures) { base.Test(failures); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestCapabilities()); } diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index a671b4093..82849a084 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Torznab { @@ -91,7 +92,7 @@ private TorznabSettings GetSettings(string url, string apiPath = null, int[] cat protected override void Test(List failures) { base.Test(failures); - if (failures.Any()) return; + if (failures.HasErrors()) return; failures.AddIfNotNull(TestCapabilities()); } diff --git a/src/NzbDrone.Core/Validation/NzbDroneValidationExtensions.cs b/src/NzbDrone.Core/Validation/NzbDroneValidationExtensions.cs index f66aed768..648e0316c 100644 --- a/src/NzbDrone.Core/Validation/NzbDroneValidationExtensions.cs +++ b/src/NzbDrone.Core/Validation/NzbDroneValidationExtensions.cs @@ -1,5 +1,7 @@ +using System.Collections.Generic; using System.Linq; using FluentValidation; +using FluentValidation.Results; namespace NzbDrone.Core.Validation { @@ -19,5 +21,21 @@ public static void ThrowOnError(this NzbDroneValidationResult result) throw new ValidationException(result.Errors); } } + + public static bool HasErrors(this List list) + { + foreach (var item in list) + { + var extended = item as NzbDroneValidationFailure; + if (extended != null && extended.IsWarning) + { + continue; + } + + return true; + } + + return false; + } } }