mirror of https://github.com/lidarr/Lidarr
Fixed: Regression preventing new downloads from bypassing the Download Client Back-off logic
This commit is contained in:
parent
2afa6c02de
commit
eed81144f6
|
@ -204,18 +204,26 @@ namespace NzbDrone.Core.Test.Download
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_attempt_download_if_client_is_disabled()
|
public void should_attempt_download_even_if_client_is_disabled()
|
||||||
{
|
{
|
||||||
WithUsenetClient();
|
var mockUsenet = WithUsenetClient();
|
||||||
|
|
||||||
Mocker.GetMock<IDownloadClientStatusService>()
|
Mocker.GetMock<IDownloadClientStatusService>()
|
||||||
.Setup(v => v.IsDisabled(It.IsAny<int>()))
|
.Setup(v => v.GetBlockedProviders())
|
||||||
.Returns(true);
|
.Returns(new List<DownloadClientStatus>
|
||||||
|
{
|
||||||
|
new DownloadClientStatus
|
||||||
|
{
|
||||||
|
ProviderId = _downloadClients.First().Definition.Id,
|
||||||
|
DisabledTill = DateTime.UtcNow.AddHours(3)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
Subject.DownloadReport(_parseResult);
|
||||||
|
|
||||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Never());
|
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
|
||||||
VerifyEventNotPublished<AlbumGrabbedEvent>();
|
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteAlbum>()), Times.Once());
|
||||||
|
VerifyEventPublished<AlbumGrabbedEvent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -55,11 +55,6 @@ namespace NzbDrone.Core.Download
|
||||||
throw new DownloadClientUnavailableException($"{remoteAlbum.Release.DownloadProtocol} Download client isn't configured yet");
|
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.
|
// Limit grabs to 2 per second.
|
||||||
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace NzbDrone.Core.ThingiProvider.Status
|
||||||
public interface IProviderStatusServiceBase<TModel>
|
public interface IProviderStatusServiceBase<TModel>
|
||||||
where TModel : ProviderStatusBase, new()
|
where TModel : ProviderStatusBase, new()
|
||||||
{
|
{
|
||||||
bool IsDisabled(int providerId);
|
|
||||||
List<TModel> GetBlockedProviders();
|
List<TModel> GetBlockedProviders();
|
||||||
void RecordSuccess(int providerId);
|
void RecordSuccess(int providerId);
|
||||||
void RecordFailure(int providerId, TimeSpan minimumBackOff = default(TimeSpan));
|
void RecordFailure(int providerId, TimeSpan minimumBackOff = default(TimeSpan));
|
||||||
|
@ -38,11 +37,6 @@ namespace NzbDrone.Core.ThingiProvider.Status
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDisabled(int providerId)
|
|
||||||
{
|
|
||||||
return GetProviderStatus(providerId).IsDisabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual List<TModel> GetBlockedProviders()
|
public virtual List<TModel> GetBlockedProviders()
|
||||||
{
|
{
|
||||||
return _providerStatusRepository.All().Where(v => v.IsDisabled()).ToList();
|
return _providerStatusRepository.All().Where(v => v.IsDisabled()).ToList();
|
||||||
|
|
Loading…
Reference in New Issue