From a843a46fbec061900ed7da85531564fef8a3528a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 18 Oct 2024 05:45:03 +0300 Subject: [PATCH] Improve message for grab errors due to no matching tags Co-authored-by: zakary (cherry picked from commit df672487cf1d5f067849367a2bfb0068defc315d) Closes #5182 --- .../Download/DownloadClientProviderFixture.cs | 10 +--------- .../Download/DownloadClientProvider.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs index 8c6ed9fd2..6476f4483 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs @@ -201,16 +201,8 @@ namespace NzbDrone.Core.Test.Download var clientTags = new HashSet { 1 }; WithTorrentClient(0, clientTags); - WithTorrentClient(0, clientTags); - WithTorrentClient(0, clientTags); - WithTorrentClient(0, clientTags); - - var client1 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags); - var client2 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags); - var client3 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags); - var client4 = Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags); - Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags).Should().BeNull(); + Assert.Throws(() => Subject.GetDownloadClient(DownloadProtocol.Torrent, 0, false, seriesTags)); } [Test] diff --git a/src/NzbDrone.Core/Download/DownloadClientProvider.cs b/src/NzbDrone.Core/Download/DownloadClientProvider.cs index 769928f2f..c6d58b1b2 100644 --- a/src/NzbDrone.Core/Download/DownloadClientProvider.cs +++ b/src/NzbDrone.Core/Download/DownloadClientProvider.cs @@ -41,18 +41,23 @@ namespace NzbDrone.Core.Download var blockedProviders = new HashSet(_downloadClientStatusService.GetBlockedProviders().Select(v => v.ProviderId)); var availableProviders = _downloadClientFactory.GetAvailableProviders().Where(v => v.Protocol == downloadProtocol).ToList(); - if (tags != null) + if (!availableProviders.Any()) + { + return null; + } + + if (tags is { Count: > 0 }) { var matchingTagsClients = availableProviders.Where(i => i.Definition.Tags.Intersect(tags).Any()).ToList(); availableProviders = matchingTagsClients.Count > 0 ? matchingTagsClients : availableProviders.Where(i => i.Definition.Tags.Empty()).ToList(); - } - if (!availableProviders.Any()) - { - return null; + if (!availableProviders.Any()) + { + throw new DownloadClientUnavailableException("No download client was found without tags or a matching artist tag. Please check your settings."); + } } if (indexerId > 0)