From 0496e6afc293ff86c570944a7728b1667f2d0933 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 25 Aug 2019 00:48:02 -0400 Subject: [PATCH] Fixed: Repack don't being grabbed when cutoff already met Co-Authored-By: Mark McDowall --- .../CutoffSpecificationFixture.cs | 18 ++++++++++++++++++ .../Specifications/UpgradableSpecification.cs | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs index ce2484151..66b8df8aa 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs @@ -101,5 +101,23 @@ namespace NzbDrone.Core.Test.DecisionEngineTests new QualityModel(Quality.FLAC, new Revision(version: 2)), 10).Should().BeTrue(); } + + + [Test] + public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade() + { + QualityProfile _profile = new QualityProfile + { + Cutoff = Quality.MP3_320.Id, + Items = Qualities.QualityFixture.GetDefaultQualities(), + }; + + Subject.CutoffNotMet( + _profile, + new List { new QualityModel(Quality.FLAC, new Revision(version: 1)) }, + NoPreferredWordScore, + new QualityModel(Quality.FLAC, new Revision(version: 2)), + NoPreferredWordScore).Should().BeTrue(); + } } } diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs index 3b01f5e3e..0057b3f67 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs @@ -94,14 +94,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications public bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null) { - var qualityCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, profile.Cutoff); + var cutoffCompare = new QualityModelComparer(profile).Compare(currentQuality.Quality.Id, profile.Cutoff); - if (qualityCompare < 0) + if (cutoffCompare < 0) { return true; } - if (qualityCompare == 0 && newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) + if (newQuality != null && IsRevisionUpgrade(currentQuality, newQuality)) { return true; }