diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index e3ff96a2b..cd638b506 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -5,6 +5,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.Books; +using NzbDrone.Core.Configuration; using NzbDrone.Core.CustomFormats; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download.TrackedDownloads; @@ -369,5 +370,31 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue(); } + + [Test] + public void should_return_false_if_same_quality_non_proper_in_queue_and_download_propers_is_do_not_upgrade() + { + _remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.FLAC, new Revision(2)); + _author.QualityProfile.Value.Cutoff = _remoteBook.ParsedBookInfo.Quality.Quality.Id; + + Mocker.GetMock() + .Setup(s => s.DownloadPropersAndRepacks) + .Returns(ProperDownloadTypes.DoNotUpgrade); + + var remoteBook = Builder.CreateNew() + .With(r => r.Author = _author) + .With(r => r.Books = new List { _book }) + .With(r => r.ParsedBookInfo = new ParsedBookInfo + { + Quality = new QualityModel(Quality.FLAC) + }) + .With(r => r.Release = _releaseInfo) + .With(r => r.CustomFormats = new List()) + .Build(); + + GivenQueue(new List { remoteBook }); + + Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs index cadc79f67..9c179fc0e 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Core.Configuration; using NzbDrone.Core.CustomFormats; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.IndexerSearch.Definitions; @@ -15,16 +16,19 @@ namespace NzbDrone.Core.DecisionEngine.Specifications private readonly IQueueService _queueService; private readonly UpgradableSpecification _upgradableSpecification; private readonly ICustomFormatCalculationService _formatService; + private readonly IConfigService _configService; private readonly Logger _logger; public QueueSpecification(IQueueService queueService, UpgradableSpecification upgradableSpecification, ICustomFormatCalculationService formatService, + IConfigService configService, Logger logger) { _queueService = queueService; _upgradableSpecification = upgradableSpecification; _formatService = formatService; + _configService = configService; _logger = logger; } @@ -85,6 +89,15 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades"); } + + if (_upgradableSpecification.IsRevisionUpgrade(remoteBook.ParsedBookInfo.Quality, subject.ParsedBookInfo.Quality)) + { + if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotUpgrade) + { + _logger.Debug("Auto downloading of propers is disabled"); + return Decision.Reject("Proper downloading is disabled"); + } + } } return Decision.Accept();