mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
Fixed: Avoid upgrades for custom formats cut-off already met
This commit is contained in:
parent
2ecc57cd31
commit
d64ee6681f
@ -11,8 +11,8 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
|||||||
public interface IUpgradableSpecification
|
public interface IUpgradableSpecification
|
||||||
{
|
{
|
||||||
bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats);
|
bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats);
|
||||||
bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentFormats, QualityModel newQuality = null);
|
|
||||||
bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null);
|
bool QualityCutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null);
|
||||||
|
bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentFormats, QualityModel newQuality = null);
|
||||||
bool IsRevisionUpgrade(QualityModel currentQuality, QualityModel newQuality);
|
bool IsRevisionUpgrade(QualityModel currentQuality, QualityModel newQuality);
|
||||||
bool IsUpgradeAllowed(QualityProfile qualityProfile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats);
|
bool IsUpgradeAllowed(QualityProfile qualityProfile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats);
|
||||||
}
|
}
|
||||||
@ -28,9 +28,9 @@ public UpgradableSpecification(IConfigService configService, Logger logger)
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats)
|
public bool IsUpgradable(QualityProfile qualityProfile, QualityModel currentQuality, List<CustomFormat> currentCustomFormats, QualityModel newQuality, List<CustomFormat> newCustomFormats)
|
||||||
{
|
{
|
||||||
var qualityComparer = new QualityModelComparer(profile);
|
var qualityComparer = new QualityModelComparer(qualityProfile);
|
||||||
var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality);
|
var qualityCompare = qualityComparer.Compare(newQuality?.Quality, currentQuality.Quality);
|
||||||
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
|
var downloadPropersAndRepacks = _configService.DownloadPropersAndRepacks;
|
||||||
|
|
||||||
@ -57,9 +57,6 @@ public bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, Li
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentFormatScore = profile.CalculateCustomFormatScore(currentCustomFormats);
|
|
||||||
var newFormatScore = profile.CalculateCustomFormatScore(newCustomFormats);
|
|
||||||
|
|
||||||
// Reject unless the user does not prefer propers/repacks and it's a revision downgrade.
|
// Reject unless the user does not prefer propers/repacks and it's a revision downgrade.
|
||||||
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
|
if (downloadPropersAndRepacks != ProperDownloadTypes.DoNotPrefer &&
|
||||||
qualityRevisionCompare < 0)
|
qualityRevisionCompare < 0)
|
||||||
@ -68,6 +65,18 @@ public bool IsUpgradable(QualityProfile profile, QualityModel currentQuality, Li
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentFormatScore = qualityProfile.CalculateCustomFormatScore(currentCustomFormats);
|
||||||
|
var newFormatScore = qualityProfile.CalculateCustomFormatScore(newCustomFormats);
|
||||||
|
|
||||||
|
if (qualityProfile.UpgradeAllowed && currentFormatScore >= qualityProfile.CutoffFormatScore)
|
||||||
|
{
|
||||||
|
_logger.Debug("Existing item meets cut-off for custom formats, skipping. Existing: [{0}] ({1}). Cutoff score: {2}",
|
||||||
|
currentCustomFormats.ConcatToString(),
|
||||||
|
currentFormatScore,
|
||||||
|
qualityProfile.CutoffFormatScore);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (newFormatScore <= currentFormatScore)
|
if (newFormatScore <= currentFormatScore)
|
||||||
{
|
{
|
||||||
_logger.Debug("New item's custom formats [{0}] ({1}) do not improve on [{2}] ({3}), skipping",
|
_logger.Debug("New item's custom formats [{0}] ({1}) do not improve on [{2}] ({3}), skipping",
|
||||||
@ -123,7 +132,7 @@ public bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, Li
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug("Existing item meets cut-off. skipping. Existing: {0}", currentQuality);
|
_logger.Debug("Existing item meets cut-off, skipping. Existing: {0}", currentQuality);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user