From 50ac0c82352515576242fa72c887d9aee4f43cdd 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 | 5 +---- .../Clients/Transmission/TransmissionBase.cs | 2 +- .../Download/Clients/rTorrent/RTorrent.cs | 2 +- .../Download/Clients/uTorrent/UTorrent.cs | 2 +- src/NzbDrone.Core/Indexers/Newznab/Newznab.cs | 4 ++-- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 4 ++-- .../Validation/NzbDroneValidationExtensions.cs | 18 ++++++++++++++++++ 11 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index f825041cb..655e30ab8 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -197,7 +197,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge 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 35bfc516d..d10d8541c 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -197,7 +197,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation 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 7dc638c57..ac55aad0a 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -192,7 +192,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation 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 60c30f61c..c283840f9 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken 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 6ac50635f..2fb69a891 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -215,10 +215,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent 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 036acd65b..74105da47 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission 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 edf12de2b..d59996e97 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -163,7 +163,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent 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 041293ce3..abb022c6c 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -224,7 +224,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent 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 cb2be8f96..1cae12b92 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -8,6 +8,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Newznab { @@ -91,8 +92,7 @@ namespace NzbDrone.Core.Indexers.Newznab 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 e121bbb06..1847aca49 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Newznab; using NzbDrone.Core.Parser; using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Torznab { @@ -72,8 +73,7 @@ namespace NzbDrone.Core.Indexers.Torznab 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 @@ namespace NzbDrone.Core.Validation 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; + } } }