mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Fixed a bunch of specs that handled propers and cutoffs
This commit is contained in:
parent
edfd527901
commit
fc43db164b
8 changed files with 235 additions and 64 deletions
|
@ -10,16 +10,15 @@ namespace NzbDrone.Core.DecisionEngine
|
|||
{
|
||||
bool IsUpgradable(QualityModel currentQuality, QualityModel newQuality = null);
|
||||
bool CutoffNotMet(QualityProfile profile, QualityModel currentQuality, QualityModel newQuality = null);
|
||||
bool IsProperUpgrade(QualityModel currentQuality, QualityModel newQuality);
|
||||
}
|
||||
|
||||
public class QualityUpgradableSpecification : IQualityUpgradableSpecification
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public QualityUpgradableSpecification(IConfigService configService, Logger logger)
|
||||
public QualityUpgradableSpecification(Logger logger)
|
||||
{
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -33,9 +32,8 @@ namespace NzbDrone.Core.DecisionEngine
|
|||
return false;
|
||||
}
|
||||
|
||||
if (currentQuality.Quality == newQuality.Quality && newQuality.Proper && _configService.AutoDownloadPropers)
|
||||
if (IsProperUpgrade(currentQuality, newQuality))
|
||||
{
|
||||
_logger.Trace("Upgrading existing item to proper.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,11 +45,27 @@ namespace NzbDrone.Core.DecisionEngine
|
|||
{
|
||||
if (currentQuality.Quality >= profile.Cutoff)
|
||||
{
|
||||
if (newQuality != null && IsProperUpgrade(currentQuality, newQuality))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Trace("Existing item meets cut-off. skipping.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsProperUpgrade(QualityModel currentQuality, QualityModel newQuality)
|
||||
{
|
||||
if (currentQuality.Quality == newQuality.Quality && newQuality > currentQuality)
|
||||
{
|
||||
_logger.Trace("New quality is a proper for existing quality");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue