Backlog searching will be disabled by default. Option is available in Settings/Misc

pull/3113/head
Mark McDowall 13 years ago
parent 3e9593ba3b
commit 11b6720cd1

@ -3,6 +3,7 @@ using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Jobs
@ -12,15 +13,17 @@ namespace NzbDrone.Core.Jobs
private readonly EpisodeProvider _episodeProvider;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly SeasonSearchJob _seasonSearchJob;
private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
SeasonSearchJob seasonSearchJob)
SeasonSearchJob seasonSearchJob, ConfigProvider configProvider)
{
_episodeProvider = episodeProvider;
_episodeSearchJob = episodeSearchJob;
_seasonSearchJob = seasonSearchJob;
_configProvider = configProvider;
}
public string Name
@ -35,6 +38,12 @@ namespace NzbDrone.Core.Jobs
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
if (!_configProvider.EnableBacklogSearching)
{
Logger.Trace("Backlog searching is not enabled, aborting job.");
return;
}
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(true)
.GroupBy(e => new { e.SeriesId, e.SeasonNumber });

@ -3,6 +3,7 @@ using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Jobs
{
@ -10,13 +11,16 @@ namespace NzbDrone.Core.Jobs
{
private readonly EpisodeProvider _episodeProvider;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob)
public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
ConfigProvider configProvider)
{
_episodeProvider = episodeProvider;
_episodeSearchJob = episodeSearchJob;
_configProvider = configProvider;
}
public string Name
@ -31,6 +35,12 @@ namespace NzbDrone.Core.Jobs
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
if (!_configProvider.EnableBacklogSearching)
{
Logger.Trace("Backlog searching is not enabled, aborting job.");
return;
}
//Get episodes that are considered missing and aired in the last 30 days
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(true).Where(e => e.AirDate >= DateTime.Today.AddDays(-30));

@ -396,6 +396,12 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("ProwlPriority", value); }
}
public virtual bool EnableBacklogSearching
{
get { return GetValueBoolean("EnableBacklogSearching"); }
set { SetValue("EnableBacklogSearching", value); }
}
private string GetValue(string key)
{
return GetValue(key, String.Empty);

@ -221,6 +221,14 @@ namespace NzbDrone.Web.Controllers
return View(model);
}
public ActionResult Misc()
{
var model = new MiscSettingsModel();
model.EnableBacklogSearching = _configProvider.EnableBacklogSearching;
return View(model);
}
public PartialViewResult AddProfile()
{
var qualityProfile = new QualityProfile
@ -582,6 +590,19 @@ namespace NzbDrone.Web.Controllers
return GetInvalidModelResult();
}
[HttpPost]
public JsonResult SaveMisc(MiscSettingsModel data)
{
if (ModelState.IsValid)
{
_configProvider.EnableBacklogSearching = data.EnableBacklogSearching;
return GetSuccessResult();
}
return GetInvalidModelResult();
}
private JsonResult GetSuccessResult()
{
return Json(new NotificationResult() { Title = "Settings Saved" });

@ -0,0 +1,15 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models
{
public class MiscSettingsModel
{
[DisplayName("Enable Backlog Searching")]
[Description("Should NzbDrone try tp download missing episodes automatically?")]
public bool EnableBacklogSearching { get; set; }
}
}

@ -226,6 +226,7 @@
<Compile Include="Helpers\DescriptionExtension.cs" />
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\MiscSettingsModel.cs" />
<Compile Include="Models\QualityProfileModel.cs" />
<Compile Include="Models\FooterModel.cs" />
<Compile Include="Models\ExistingSeriesModel.cs" />
@ -525,6 +526,9 @@
<ItemGroup>
<Content Include="Views\Shared\_ReferenceLayout.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Settings\Misc.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -9,6 +9,7 @@
<li>@Html.ActionLink("SABnzbd", "Sabnzbd", "Settings")</li>
<li>@Html.ActionLink("Notifications", "Notifications", "Settings")</li>
<li>@Html.ActionLink("System", "System", "Settings")</li>
<li>@Html.ActionLink("Misc", "Misc", "Settings")</li>
</ul>
</div>

@ -0,0 +1,24 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.MiscSettingsModel
@{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; }
@section HeaderContent{
@Html.IncludeCss("Settings.css")
}
<div id="stylized">
@using (Html.BeginForm("SaveMisc", "Settings", FormMethod.Post, new { id = "MiscForm", name = "MiscForm", @class = "settingsForm" }))
{
<label class="labelClass">@Html.LabelFor(m => m.EnableBacklogSearching)
<span class="small">@Html.DescriptionFor(m => m.EnableBacklogSearching)</span>
</label>
@Html.CheckBoxFor(m => m.EnableBacklogSearching, new { @class = "inputClass checkClass" })
<div style="overflow: hidden; height: 50px;"></div>
<button type="submit" class="save_button" disabled="disabled">
Save</button>
}
</div>
@section Scripts{
}
Loading…
Cancel
Save