mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-26 15:52:42 +00:00
Fixed: Don't attempt to fetch a release if the download client is disabled
This commit is contained in:
parent
bff3a55ff3
commit
d3aa032cf5
3 changed files with 27 additions and 1 deletions
|
@ -180,7 +180,7 @@ public void Download_report_should_not_trigger_indexer_backoff_on_downloadclient
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_download_if_client_isnt_configure()
|
||||
public void should_not_attempt_download_if_client_isnt_configured()
|
||||
{
|
||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
||||
|
@ -188,6 +188,21 @@ public void should_not_attempt_download_if_client_isnt_configure()
|
|||
VerifyEventNotPublished<AlbumGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_download_if_client_is_disabled()
|
||||
{
|
||||
WithUsenetClient();
|
||||
|
||||
Mocker.GetMock<IDownloadClientStatusService>()
|
||||
.Setup(v => v.IsDisabled(It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Never());
|
||||
VerifyEventNotPublished<AlbumGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_send_download_to_correct_usenet_client()
|
||||
{
|
||||
|
|
|
@ -55,6 +55,11 @@ public void DownloadReport(RemoteAlbum remoteAlbum)
|
|||
throw new DownloadClientUnavailableException($"{remoteAlbum.Release.DownloadProtocol} Download client isn't configured yet");
|
||||
}
|
||||
|
||||
if (_downloadClientStatusService.IsDisabled(downloadClient.Definition.Id))
|
||||
{
|
||||
throw new DownloadClientUnavailableException($"{downloadClient.Name} is disabled due to recent failues");
|
||||
}
|
||||
|
||||
// Limit grabs to 2 per second.
|
||||
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
|
|||
public interface IProviderStatusServiceBase<TModel>
|
||||
where TModel : ProviderStatusBase, new()
|
||||
{
|
||||
bool IsDisabled(int providerId);
|
||||
List<TModel> GetBlockedProviders();
|
||||
void RecordSuccess(int providerId);
|
||||
void RecordFailure(int providerId, TimeSpan minimumBackOff = default(TimeSpan));
|
||||
|
@ -37,6 +38,11 @@ public ProviderStatusServiceBase(IProviderStatusRepository<TModel> providerStatu
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public bool IsDisabled(int providerId)
|
||||
{
|
||||
return GetProviderStatus(providerId).IsDisabled();
|
||||
}
|
||||
|
||||
public virtual List<TModel> GetBlockedProviders()
|
||||
{
|
||||
return _providerStatusRepository.All().Where(v => v.IsDisabled()).ToList();
|
||||
|
|
Loading…
Reference in a new issue