diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs index cb326ba7a..6733bcde8 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientProviderFixture.cs @@ -200,17 +200,9 @@ public void should_fail_to_choose_when_clients_have_tags_but_no_match() var seriesTags = new HashSet { 2 }; 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..9a4eb8795 100644 --- a/src/NzbDrone.Core/Download/DownloadClientProvider.cs +++ b/src/NzbDrone.Core/Download/DownloadClientProvider.cs @@ -41,18 +41,23 @@ public IDownloadClient GetDownloadClient(DownloadProtocol downloadProtocol, int 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 movie tag. Please check your settings."); + } } if (indexerId > 0)