From 0ef8f2b2f72912a5841045bedf545985c3984b9a Mon Sep 17 00:00:00 2001 From: Robin Dadswell Date: Mon, 11 Jan 2021 16:53:56 +0000 Subject: [PATCH] finished fixing IsUpgradable --- .../Specifications/UpgradableSpecification.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs index 8b7de976e..b8edfdce0 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradableSpecification.cs @@ -13,7 +13,7 @@ public interface IUpgradableSpecification bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null); bool CutoffNotMet(QualityProfile profile, List currentQualities, int currentScore, QualityModel newQuality = null, int newScore = 0); bool IsRevisionUpgrade(QualityModel currentQuality, QualityModel newQuality); - bool IsUpgradeAllowed(QualityProfile qualityProfile, List currentQualities, QualityModel newQuality); + bool IsUpgradeAllowed(QualityProfile qualityProfile, QualityModel currentQuality, QualityModel newQuality); } public class UpgradableSpecification : IUpgradableSpecification @@ -49,12 +49,13 @@ private ProfileComparisonResult IsQualityUpgradable(QualityProfile profile, Qual return ProfileComparisonResult.Equal; } - // Quality Treated as Equal if Propers are not Prefered - if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer && - newQuality.Revision.CompareTo(currentQualities(q => q.Revision)) > 0) - { - return ProfileComparisonResult.Equal; - } + // Accept unless the user doesn't want to prefer propers, optionally they can + // use preferred words to prefer propers/repacks over non-propers/repacks. + if (_configService.DownloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer && + newQuality?.Revision.CompareTo(currentQuality.Revision) > 0) + { + return ProfileComparisonResult.Upgrade; + } } return ProfileComparisonResult.Upgrade; @@ -144,9 +145,9 @@ public bool IsRevisionUpgrade(QualityModel currentQuality, QualityModel newQuali return false; } - public bool IsUpgradeAllowed(QualityProfile qualityProfile, List currentQualities, QualityModel newQuality) + public bool IsUpgradeAllowed(QualityProfile qualityProfile, QualityModel currentQuality, QualityModel newQuality) { - var isQualityUpgrade = IsQualityUpgradable(qualityProfile, currentQualities, newQuality); + var isQualityUpgrade = IsQualityUpgradable(qualityProfile, currentQuality, newQuality); return CheckUpgradeAllowed(qualityProfile, isQualityUpgrade); }