Retention check added to DecisionEngine.

Retention is configurable from Settings/Indexers.
pull/3113/head
Mark McDowall 13 years ago committed by kay.one
parent 8c0efac00b
commit 462eb53897

@ -40,6 +40,8 @@ namespace NzbDrone.Core.Model
public long Size { get; set; }
public int Age { get; set; }
public override string ToString()
{
if (AirDate != null && EpisodeNumbers == null)

@ -261,6 +261,7 @@
<Compile Include="Model\Xbmc\IconType.cs" />
<Compile Include="Providers\BackupProvider.cs" />
<Compile Include="Providers\DecisionEngine\AlreadyInQueueSpecification.cs" />
<Compile Include="Providers\DecisionEngine\RetentionSpecification.cs" />
<Compile Include="Providers\DownloadClients\BlackholeProvider.cs" />
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />

@ -413,6 +413,12 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("AutoIgnorePreviouslyDownloadedEpisodes", value); }
}
public virtual int Retention
{
get { return GetValueInt("Retention", 0); }
set { SetValue("Retention", value); }
}
public Guid UGuid
{
get { return Guid.Parse(GetValue("UGuid", Guid.NewGuid().ToString(), persist: true)); }

@ -11,17 +11,19 @@ namespace NzbDrone.Core.Providers.DecisionEngine
private readonly UpgradeDiskSpecification _upgradeDiskSpecification;
private readonly AcceptableSizeSpecification _acceptableSizeSpecification;
private readonly AlreadyInQueueSpecification _alreadyInQueueSpecification;
private readonly RetentionSpecification _retentionSpecification;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
[Inject]
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
AlreadyInQueueSpecification alreadyInQueueSpecification)
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification)
{
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
_upgradeDiskSpecification = upgradeDiskSpecification;
_acceptableSizeSpecification = acceptableSizeSpecification;
_alreadyInQueueSpecification = alreadyInQueueSpecification;
_retentionSpecification = retentionSpecification;
}
public AllowedDownloadSpecification()
@ -32,6 +34,7 @@ namespace NzbDrone.Core.Providers.DecisionEngine
{
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return false;
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return false;
if (!_retentionSpecification.IsSatisfiedBy(subject)) return false;
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return false;
if (_alreadyInQueueSpecification.IsSatisfiedBy(subject)) return false;

@ -0,0 +1,35 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.DecisionEngine
{
public class RetentionSpecification
{
private readonly ConfigProvider _configProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public RetentionSpecification(ConfigProvider configProvider)
{
_configProvider = configProvider;
}
public RetentionSpecification()
{
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Checking if report meets retention requirements. {0}", subject.Age);
if (_configProvider.Retention > 0 && subject.Age > _configProvider.Retention)
{
logger.Trace("Quality {0} rejected by user's retention limit", subject.Age);
return false;
}
return true;
}
}
}

@ -67,6 +67,8 @@ namespace NzbDrone.Web.Controllers
{
return View(new IndexerSettingsModel
{
Retention = _configProvider.Retention,
NzbMatrixUsername = _configProvider.NzbMatrixUsername,
NzbMatrixApiKey = _configProvider.NzbMatrixApiKey,
@ -338,6 +340,8 @@ namespace NzbDrone.Web.Controllers
{
if (ModelState.IsValid)
{
_configProvider.Retention = data.Retention;
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrg));
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
_indexerProvider.SaveSettings(nzbsOrgSettings);

@ -76,6 +76,12 @@ namespace NzbDrone.Web.Models
[Description("Enable downloading episodes from Newznab Providers")]
public bool NewznabEnabled { get; set; }
[Required(ErrorMessage = "Please enter a valid number of days")]
[DataType(DataType.Text)]
[DisplayName("Retention")]
[Description("Usenet provider retention in days (0 = unlimited)")]
public int Retention { get; set; }
public List<NewznabDefinition> NewznabDefinitions { get; set; }
}
}

@ -9,14 +9,19 @@
{
overflow: auto;
}
.retentionContainer
{
padding-top: 20px;
overflow: hidden;
}
</style>
}
<div class="infoBox">
RSS feeds are checked every 25 minutes for new episodes.</div>
<div id="stylized">
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
{
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
{
<div class="jquery-accordion">
<h3>
<a href="#">NZBs.org</a></h3>
@ -106,7 +111,16 @@
</div>
</div>
</div>
<br />
<div class="retentionContainer">
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
<label class="labelClass">@Html.LabelFor(m => m.Retention)
<span class="small">@Html.DescriptionFor(m => m.Retention)</span>
</label>
@Html.TextBoxFor(m => m.Retention, new { @class = "inputClass" })
</div>
<button type="submit" class="save_button" disabled="disabled">
Save</button>
}

Loading…
Cancel
Save