2013-03-07 03:19:49 +03:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Model;
|
2013-04-15 04:41:39 +03:00
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2013-03-07 03:19:49 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
|
|
{
|
2013-04-07 10:30:37 +03:00
|
|
|
public class RetentionSpecification : IDecisionEngineSpecification
|
2013-03-07 03:19:49 +03: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 04:41:39 +03:00
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
2013-03-07 03:19:49 +03:00
|
|
|
{
|
2013-04-15 04:41:39 +03: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 03:19:49 +03:00
|
|
|
{
|
2013-04-15 04:41:39 +03:00
|
|
|
_logger.Trace("Report age: {0} rejected by user's retention limit", age);
|
2013-03-07 03:19:49 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|