From a4d6851be10b4dd96fdc91ea450cf2bfdfd33c91 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 11 Aug 2013 23:00:40 -0700 Subject: [PATCH] Added option to not auto download propers --- .../QualityUpgradeSpecificationFixture.cs | 20 +++++++++++++++++++ .../UpgradeHistorySpecificationFixture.cs | 2 +- NzbDrone.Core/Configuration/ConfigService.cs | 7 +++++++ NzbDrone.Core/Configuration/IConfigService.cs | 1 + .../QualityUpgradableSpecification.cs | 7 +++++-- .../UpgradeHistorySpecification.cs | 2 +- NzbDrone.Core/NzbDrone.Core.csproj | 2 +- .../FileManagement/ViewTemplate.html | 20 +++++++++++++++++++ 8 files changed, 56 insertions(+), 5 deletions(-) rename NzbDrone.Core/DecisionEngine/Specifications/{ => RssSync}/UpgradeHistorySpecification.cs (96%) diff --git a/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs index 21ab11a5b..2a489ee8a 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs @@ -1,5 +1,6 @@ using FluentAssertions; using NUnit.Framework; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.DecisionEngine; @@ -24,11 +25,30 @@ namespace NzbDrone.Core.Test.DecisionEngineTests new object[] { Quality.WEBDL1080p, false, Quality.WEBDL1080p, false, Quality.WEBDL1080p, false } }; + private void GivenAutoDownloadPropers(bool autoDownloadPropers) + { + Mocker.GetMock() + .SetupGet(s => s.AutoDownloadPropers) + .Returns(autoDownloadPropers); + } + [Test, TestCaseSource("IsUpgradeTestCases")] public void IsUpgradeTest(Quality current, bool currentProper, Quality newQuality, bool newProper, Quality cutoff, bool expected) { + GivenAutoDownloadPropers(true); + Subject.IsUpgradable(new QualityProfile() { Cutoff = cutoff }, new QualityModel(current, currentProper), new QualityModel(newQuality, newProper)) .Should().Be(expected); } + + [Test] + public void should_return_false_if_proper_and_autoDownloadPropers_is_false() + { + GivenAutoDownloadPropers(false); + + Subject.IsUpgradable(new QualityProfile { Cutoff = Quality.Bluray1080p }, + new QualityModel(Quality.DVD, true), + new QualityModel(Quality.DVD, false)).Should().BeFalse(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs index 454ac01f5..70e81dc8a 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs @@ -2,7 +2,7 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications; +using NzbDrone.Core.DecisionEngine.Specifications.RssSync; using NzbDrone.Core.History; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs index 3596d596a..a98e06cb5 100644 --- a/NzbDrone.Core/Configuration/ConfigService.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -251,6 +251,13 @@ namespace NzbDrone.Core.Configuration set { SetValue("RssSyncInterval", value); } } + public Boolean AutoDownloadPropers + { + get { return GetValueBoolean("AutoDownloadPropers", true); } + + set { SetValue("AutoDownloadPropers", value); } + } + private string GetValue(string key) { return GetValue(key, String.Empty); diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs index b71671b13..0b5779a37 100644 --- a/NzbDrone.Core/Configuration/IConfigService.cs +++ b/NzbDrone.Core/Configuration/IConfigService.cs @@ -37,6 +37,7 @@ namespace NzbDrone.Core.Configuration PriorityType NzbgetOlderTvPriority { get; set; } string ReleaseRestrictions { get; set; } Int32 RssSyncInterval { get; set; } + Boolean AutoDownloadPropers { get; set; } void SaveValues(Dictionary configValues); } } diff --git a/NzbDrone.Core/DecisionEngine/QualityUpgradableSpecification.cs b/NzbDrone.Core/DecisionEngine/QualityUpgradableSpecification.cs index f99e9f46b..8fbd65d1a 100644 --- a/NzbDrone.Core/DecisionEngine/QualityUpgradableSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/QualityUpgradableSpecification.cs @@ -1,4 +1,5 @@ using NLog; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; @@ -11,10 +12,12 @@ namespace NzbDrone.Core.DecisionEngine public class QualityUpgradableSpecification : IQualityUpgradableSpecification { + private readonly IConfigService _configService; private readonly Logger _logger; - public QualityUpgradableSpecification(Logger logger) + public QualityUpgradableSpecification(IConfigService configService, Logger logger) { + _configService = configService; _logger = logger; } @@ -28,7 +31,7 @@ namespace NzbDrone.Core.DecisionEngine return false; } - if (currentQuality.Quality == newQuality.Quality && newQuality.Proper) + if (currentQuality.Quality == newQuality.Quality && newQuality.Proper && _configService.AutoDownloadPropers) { _logger.Trace("Upgrading existing item to proper."); return true; diff --git a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/RssSync/UpgradeHistorySpecification.cs similarity index 96% rename from NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs rename to NzbDrone.Core/DecisionEngine/Specifications/RssSync/UpgradeHistorySpecification.cs index 8a95198ff..21611c161 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/UpgradeHistorySpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/RssSync/UpgradeHistorySpecification.cs @@ -3,7 +3,7 @@ using NzbDrone.Core.History; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; -namespace NzbDrone.Core.DecisionEngine.Specifications +namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync { public class UpgradeHistorySpecification : IDecisionEngineSpecification { diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 12c61a20d..17bfa17b7 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -186,7 +186,7 @@ - + diff --git a/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html b/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html index 0df4a37b8..5f5b5c052 100644 --- a/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html +++ b/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html @@ -20,4 +20,24 @@ + +
+ + +
+