mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
skip queue check and adding new items if download client isn't configured correctly.
This commit is contained in:
parent
1eb278c7f6
commit
a5bb99367e
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
{
|
||||
@ -28,9 +29,12 @@ public void Setup()
|
||||
|
||||
_parseResult = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
||||
.With(c=>c.Report = Builder<ReportInfo>.CreateNew().Build())
|
||||
.With(c => c.Report = Builder<ReportInfo>.CreateNew().Build())
|
||||
.With(c => c.Episodes = episodes)
|
||||
.Build();
|
||||
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Setup(c => c.IsConfigured).Returns(true);
|
||||
}
|
||||
|
||||
private void WithSuccessfulAdd()
|
||||
@ -76,5 +80,20 @@ public void Download_report_should_not_publish_on_failed_grab_event()
|
||||
Subject.DownloadReport(_parseResult);
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_download_if_client_isnt_configure()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>().Setup(c => c.IsConfigured).Returns(false);
|
||||
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.DownloadNzb(It.IsAny<RemoteEpisode>()),Times.Never());
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
@ -10,10 +11,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
public class NotInQueueSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public NotInQueueSpecification(IProvideDownloadClient downloadClientProvider)
|
||||
public NotInQueueSpecification(IProvideDownloadClient downloadClientProvider, Logger logger)
|
||||
{
|
||||
_downloadClientProvider = downloadClientProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string RejectionReason
|
||||
@ -28,6 +31,12 @@ public bool IsSatisfiedBy(RemoteEpisode subject)
|
||||
{
|
||||
var downloadClient = _downloadClientProvider.GetDownloadClient();
|
||||
|
||||
if (!downloadClient.IsConfigured)
|
||||
{
|
||||
_logger.Warn("Download client {0} isn't configured yet.", downloadClient.GetType().Name);
|
||||
return true;
|
||||
}
|
||||
|
||||
var queue = downloadClient.GetQueue().Select(queueItem => Parser.Parser.ParseTitle(queueItem.Title)).Where(episodeInfo => episodeInfo != null);
|
||||
|
||||
return !IsInQueue(subject, queue);
|
||||
|
@ -63,6 +63,14 @@ public bool DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(_configService.BlackholeFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<QueueItem> GetQueue()
|
||||
{
|
||||
return new QueueItem[0];
|
||||
|
@ -57,6 +57,14 @@ public virtual bool DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(_configService.NzbgetHost) && _configService.NzbgetPort != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<QueueItem> GetQueue()
|
||||
{
|
||||
var command = new JsonRequest
|
||||
|
@ -68,6 +68,14 @@ public virtual bool DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(_configService.PneumaticFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<QueueItem> GetQueue()
|
||||
{
|
||||
return new QueueItem[0];
|
||||
|
@ -24,7 +24,7 @@ public SabRequestBuilder(IConfigService configService)
|
||||
public IRestRequest AddToQueueRequest(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
string cat = _configService.SabTvCategory;
|
||||
int priority = (int)_configService.SabRecentTvPriority;
|
||||
int priority = (int)_configService.SabRecentTvPriority;
|
||||
|
||||
string name = remoteEpisode.Report.NzbUrl.Replace("&", "%26");
|
||||
string nzbName = HttpUtility.UrlEncode(remoteEpisode.Report.Title);
|
||||
@ -97,6 +97,15 @@ public virtual bool DownloadNzb(RemoteEpisode remoteEpisode)
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsConfigured
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(_configService.SabHost)
|
||||
&& _configService.SabPort != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<QueueItem> GetQueue()
|
||||
{
|
||||
string action = String.Format("mode=queue&output=json&start={0}&limit={1}", 0, 0);
|
||||
|
@ -27,9 +27,15 @@ public DownloadService(IProvideDownloadClient downloadClientProvider,
|
||||
public bool DownloadReport(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var downloadTitle = remoteEpisode.Report.Title;
|
||||
var provider = _downloadClientProvider.GetDownloadClient();
|
||||
var downloadClient = _downloadClientProvider.GetDownloadClient();
|
||||
|
||||
bool success = provider.DownloadNzb(remoteEpisode);
|
||||
if (!downloadClient.IsConfigured)
|
||||
{
|
||||
_logger.Warn("Download client {0} isn't configured yet.", downloadClient.GetType().Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = downloadClient.DownloadNzb(remoteEpisode);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ namespace NzbDrone.Core.Download
|
||||
public interface IDownloadClient
|
||||
{
|
||||
bool DownloadNzb(RemoteEpisode remoteEpisode);
|
||||
bool IsConfigured { get; }
|
||||
IEnumerable<QueueItem> GetQueue();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user