2012-02-07 06:08:07 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2012-04-15 03:09:51 +02:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2012-02-07 06:08:07 +01:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.DecisionEngine
|
|
|
|
|
{
|
2012-04-15 03:09:51 +02:00
|
|
|
|
public class QualityUpgradeSpecification
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2012-04-15 03:09:51 +02:00
|
|
|
|
public virtual bool IsSatisfiedBy(Quality currentQuality, Quality newQuality, QualityTypes cutOff)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2012-04-15 03:09:51 +02:00
|
|
|
|
if (currentQuality >= newQuality)
|
2012-02-07 06:08:07 +01:00
|
|
|
|
{
|
2012-04-15 03:09:51 +02: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 06:08:07 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|