From e33e45ec73fb1e56f9fc5c54c6d67d7d5808d705 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 27 Sep 2024 16:42:39 -0700 Subject: [PATCH] Fixed: Don't reject revision upgrades if profile doesn't allow upgrades (cherry picked from commit 4f0e1c54c167f5123a33d19b76653450401adb6d) --- .../UpgradeAllowedSpecificationFixture.cs | 14 ++++++++++++++ .../Specifications/UpgradableSpecification.cs | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeAllowedSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeAllowedSpecificationFixture.cs index c958dc1a6..af7444da6 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeAllowedSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/UpgradeAllowedSpecificationFixture.cs @@ -206,5 +206,19 @@ public void should_return_true_for_lower_quality_when_upgrading_is_not_allowed() new List()) .Should().BeTrue(); } + + [Test] + public void should_returntrue_when_quality_is_revision_upgrade_for_same_quality() + { + _qualityProfile.UpgradeAllowed = false; + + Subject.IsUpgradeAllowed( + _qualityProfile, + new QualityModel(Quality.DVD, new Revision(1)), + new List { _customFormatOne }, + new QualityModel(Quality.DVD, new Revision(2)), + new List { _customFormatOne }) + .Should().BeTrue(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs index 7ce091bbb..79769b4ce 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs @@ -177,6 +177,12 @@ public bool IsUpgradeAllowed(QualityProfile qualityProfile, QualityModel current var isQualityUpgrade = new QualityModelComparer(qualityProfile).Compare(newQuality, currentQuality) > 0; var isCustomFormatUpgrade = qualityProfile.CalculateCustomFormatScore(newCustomFormats) > qualityProfile.CalculateCustomFormatScore(currentCustomFormats); + if (IsRevisionUpgrade(currentQuality, newQuality)) + { + _logger.Debug("New quality '{0}' is a revision upgrade for '{1}'", newQuality, currentQuality); + return true; + } + if ((isQualityUpgrade || isCustomFormatUpgrade) && qualityProfile.UpgradeAllowed) { _logger.Debug("Quality profile allows upgrading");