2013-03-07 00:19:49 +00:00
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2013-04-15 01:41:39 +00:00
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-03-07 00:19:49 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
|
|
|
{
|
2013-04-07 07:30:37 +00:00
|
|
|
|
public class RetentionSpecification : IDecisionEngineSpecification
|
2013-03-07 00:19:49 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public RetentionSpecification(IConfigService configService, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_configService = configService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string RejectionReason
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return "Report past retention limit.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
2013-03-07 00:19:49 +00:00
|
|
|
|
{
|
2013-04-15 01:41:39 +00:00
|
|
|
|
var age = subject.Report.Age;
|
|
|
|
|
|
|
|
|
|
_logger.Trace("Checking if report meets retention requirements. {0}", age);
|
|
|
|
|
if (_configService.Retention > 0 && age > _configService.Retention)
|
2013-03-07 00:19:49 +00:00
|
|
|
|
{
|
2013-04-15 01:41:39 +00:00
|
|
|
|
_logger.Trace("Report age: {0} rejected by user's retention limit", age);
|
2013-03-07 00:19:49 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|