2012-02-07 05:08:07 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2012-04-15 01:09:51 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2012-02-07 05:08:07 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.DecisionEngine
|
|
|
|
|
{
|
2012-04-15 01:09:51 +00:00
|
|
|
|
public class QualityUpgradeSpecification
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2012-04-15 01:09:51 +00:00
|
|
|
|
public virtual bool IsSatisfiedBy(Quality currentQuality, Quality newQuality, QualityTypes cutOff)
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2012-04-15 01:09:51 +00:00
|
|
|
|
if (currentQuality >= newQuality)
|
2012-02-07 05:08:07 +00:00
|
|
|
|
{
|
2012-04-15 01:09:51 +00:00
|
|
|
|
logger.Trace("existing item has better or equal quality. skipping");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentQuality.QualityType == newQuality.QualityType && newQuality.Proper)
|
|
|
|
|
{
|
|
|
|
|
logger.Trace("Upgrading existing item to proper.");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentQuality.QualityType >= cutOff)
|
|
|
|
|
{
|
|
|
|
|
logger.Trace("Existing item meets cut-off. skipping.");
|
2012-02-07 05:08:07 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|