mirror of https://github.com/Radarr/Radarr
Delete files when deleting series
New: Option to delete files when deleting series
This commit is contained in:
parent
a7fd486b03
commit
b52dcfd2ef
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
|
||||||
|
@ -10,13 +11,15 @@ namespace NzbDrone.Core.Jobs
|
||||||
public class DeleteSeriesJob : IJob
|
public class DeleteSeriesJob : IJob
|
||||||
{
|
{
|
||||||
private readonly SeriesProvider _seriesProvider;
|
private readonly SeriesProvider _seriesProvider;
|
||||||
|
private readonly DiskProvider _diskProvider;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public DeleteSeriesJob(SeriesProvider seriesProvider)
|
public DeleteSeriesJob(SeriesProvider seriesProvider, DiskProvider diskProvider)
|
||||||
{
|
{
|
||||||
_seriesProvider = seriesProvider;
|
_seriesProvider = seriesProvider;
|
||||||
|
_diskProvider = diskProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -31,20 +34,30 @@ namespace NzbDrone.Core.Jobs
|
||||||
|
|
||||||
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
||||||
{
|
{
|
||||||
DeleteSeries(notification, targetId);
|
DeleteSeries(notification, targetId, Convert.ToBoolean(secondaryTargetId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSeries(ProgressNotification notification, int seriesId)
|
private void DeleteSeries(ProgressNotification notification, int seriesId, bool deleteFiles)
|
||||||
{
|
{
|
||||||
Logger.Trace("Deleting Series [{0}]", seriesId);
|
Logger.Trace("Deleting Series [{0}]", seriesId);
|
||||||
|
|
||||||
var title = _seriesProvider.GetSeries(seriesId).Title;
|
var series = _seriesProvider.GetSeries(seriesId);
|
||||||
|
var title = series.Title;
|
||||||
|
|
||||||
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
||||||
|
|
||||||
_seriesProvider.DeleteSeries(seriesId);
|
_seriesProvider.DeleteSeries(seriesId);
|
||||||
|
|
||||||
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
|
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
|
||||||
|
|
||||||
|
if (deleteFiles)
|
||||||
|
{
|
||||||
|
notification.CurrentMessage = String.Format("Deleting files from disk for series '{0}'", title);
|
||||||
|
|
||||||
|
_diskProvider.DeleteFolder(series.Path, true);
|
||||||
|
|
||||||
|
notification.CurrentMessage = String.Format("Successfully deleted files from disk for series '{0}'", title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -243,3 +243,7 @@ button span, input[type="button"] span, input[type="submit"] span, input[type="r
|
||||||
{
|
{
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.series-delete-files {
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ namespace NzbDrone.Web.Controllers
|
||||||
[HandleError]
|
[HandleError]
|
||||||
public class SeriesController : Controller
|
public class SeriesController : Controller
|
||||||
{
|
{
|
||||||
private readonly EpisodeProvider _episodeProvider;
|
|
||||||
private readonly QualityProvider _qualityProvider;
|
private readonly QualityProvider _qualityProvider;
|
||||||
private readonly SeriesProvider _seriesProvider;
|
private readonly SeriesProvider _seriesProvider;
|
||||||
private readonly JobProvider _jobProvider;
|
private readonly JobProvider _jobProvider;
|
||||||
|
@ -27,12 +26,11 @@ namespace NzbDrone.Web.Controllers
|
||||||
//
|
//
|
||||||
// GET: /Series/
|
// GET: /Series/
|
||||||
|
|
||||||
public SeriesController(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
public SeriesController(SeriesProvider seriesProvider,
|
||||||
QualityProvider qualityProvider, JobProvider jobProvider,
|
QualityProvider qualityProvider, JobProvider jobProvider,
|
||||||
SeasonProvider seasonProvider)
|
SeasonProvider seasonProvider)
|
||||||
{
|
{
|
||||||
_seriesProvider = seriesProvider;
|
_seriesProvider = seriesProvider;
|
||||||
_episodeProvider = episodeProvider;
|
|
||||||
_qualityProvider = qualityProvider;
|
_qualityProvider = qualityProvider;
|
||||||
_jobProvider = jobProvider;
|
_jobProvider = jobProvider;
|
||||||
_seasonProvider = seasonProvider;
|
_seasonProvider = seasonProvider;
|
||||||
|
@ -80,9 +78,9 @@ namespace NzbDrone.Web.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public EmptyResult DeleteSeries(int seriesId)
|
public EmptyResult DeleteSeries(int seriesId, bool deleteFiles)
|
||||||
{
|
{
|
||||||
_jobProvider.QueueJob(typeof(DeleteSeriesJob), seriesId);
|
_jobProvider.QueueJob(typeof(DeleteSeriesJob), seriesId, Convert.ToInt32(deleteFiles));
|
||||||
|
|
||||||
return new EmptyResult();
|
return new EmptyResult();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,21 +13,17 @@ $("#seriesEditor").dialog({
|
||||||
text: "Delete",
|
text: "Delete",
|
||||||
class: "ui-delete-button",
|
class: "ui-delete-button",
|
||||||
click: function () {
|
click: function () {
|
||||||
var answer = confirm("Are you sure you want to delete this series?");
|
$(this).dialog("close");
|
||||||
if (answer) {
|
|
||||||
var seriesId = $('#SeriesId').val();
|
|
||||||
|
|
||||||
$.ajax({
|
//Get the SeriesId and Title
|
||||||
type: "POST",
|
var seriesId = $('#SeriesId').val();
|
||||||
url: seriesDeleteUrl,
|
var title = $('[aria-labelledby="ui-dialog-title-seriesEditor"]').find('#ui-dialog-title-seriesEditor').text();
|
||||||
data: { seriesId: seriesId },
|
|
||||||
success: function (data) {
|
//Fill in the view
|
||||||
//Remove the row from the grid... along with the details row
|
$('#seriesDelete').children('.seriesId').val(seriesId);
|
||||||
afterDelete();
|
$('#seriesDelete').children('.seriesTitle').html(title);
|
||||||
}
|
|
||||||
});
|
$("#seriesDelete").dialog("open");
|
||||||
$(this).dialog("close");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Save": function () {
|
"Save": function () {
|
||||||
|
@ -52,12 +48,12 @@ $("#seriesDelete").dialog({
|
||||||
buttons: {
|
buttons: {
|
||||||
"Delete": function () {
|
"Delete": function () {
|
||||||
var seriesId = $('.seriesId').val();
|
var seriesId = $('.seriesId').val();
|
||||||
|
var deleteFiles = $('#DeleteFilesFromDisk').is(':checked');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: seriesDeleteUrl,
|
url: seriesDeleteUrl,
|
||||||
data: { seriesId: seriesId },
|
data: { seriesId: seriesId, deleteFiles: deleteFiles },
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
//Remove the row from the grid... along with the details row
|
|
||||||
afterDelete(seriesId);
|
afterDelete(seriesId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,9 +109,16 @@
|
||||||
<div style="visibility: hidden">
|
<div style="visibility: hidden">
|
||||||
<div id="seriesEditor" title="Edit Series">
|
<div id="seriesEditor" title="Edit Series">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="visibility: hidden">
|
<div id="seriesDelete" title="Delete Series">
|
||||||
|
<input class="seriesId" type="hidden" value="" />
|
||||||
|
Are you sure you want to delete '<span class="seriesTitle"></span>'?
|
||||||
|
<div class="series-delete-files">
|
||||||
|
@Html.CheckBox("DeleteFilesFromDisk")
|
||||||
|
<label for="DeleteFilesFromDisk">Delete all files from disk?</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="qualityChanger" title="Change Quality">
|
<div id="qualityChanger" title="Change Quality">
|
||||||
<label for="NewQuality">New Quality</label>
|
<label for="NewQuality">New Quality</label>
|
||||||
@Html.DropDownList("NewQuality", Model.QualitySelectList)
|
@Html.DropDownList("NewQuality", Model.QualitySelectList)
|
||||||
|
|
|
@ -88,9 +88,14 @@
|
||||||
<div style="visibility: hidden">
|
<div style="visibility: hidden">
|
||||||
<div id="seriesEditor" title="Edit Series">
|
<div id="seriesEditor" title="Edit Series">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="seriesDelete" title="Delete Series">
|
<div id="seriesDelete" title="Delete Series">
|
||||||
<input class="seriesId" type="hidden" value="" />
|
<input class="seriesId" type="hidden" value="" />
|
||||||
Are you sure you want to delete '<span class="seriesTitle"></span>'?
|
Are you sure you want to delete '<span class="seriesTitle"></span>'?
|
||||||
|
<div class="series-delete-files">
|
||||||
|
@Html.CheckBox("DeleteFromDisk")
|
||||||
|
<label for="DeleteFromDisk">Delete all files from disk?</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
|
|
Loading…
Reference in New Issue