1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 13:02:47 +01:00

Delete files when deleting series

New: Option to delete files when deleting series
This commit is contained in:
Mark McDowall 2012-09-03 17:51:07 -07:00
parent a7fd486b03
commit b52dcfd2ef
6 changed files with 50 additions and 27 deletions

View File

@ -2,6 +2,7 @@
using System;
using Ninject;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@ -10,13 +11,15 @@ namespace NzbDrone.Core.Jobs
public class DeleteSeriesJob : IJob
{
private readonly SeriesProvider _seriesProvider;
private readonly DiskProvider _diskProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DeleteSeriesJob(SeriesProvider seriesProvider)
public DeleteSeriesJob(SeriesProvider seriesProvider, DiskProvider diskProvider)
{
_seriesProvider = seriesProvider;
_diskProvider = diskProvider;
}
public string Name
@ -31,20 +34,30 @@ public TimeSpan DefaultInterval
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);
var title = _seriesProvider.GetSeries(seriesId).Title;
var series = _seriesProvider.GetSeries(seriesId);
var title = series.Title;
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
_seriesProvider.DeleteSeries(seriesId);
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);
}
}
}
}

View File

@ -243,3 +243,7 @@ button span, input[type="button"] span, input[type="submit"] span, input[type="r
{
text-decoration: underline;
}
.series-delete-files {
padding-top: 15px;
}

View File

@ -19,7 +19,6 @@ namespace NzbDrone.Web.Controllers
[HandleError]
public class SeriesController : Controller
{
private readonly EpisodeProvider _episodeProvider;
private readonly QualityProvider _qualityProvider;
private readonly SeriesProvider _seriesProvider;
private readonly JobProvider _jobProvider;
@ -27,12 +26,11 @@ public class SeriesController : Controller
//
// GET: /Series/
public SeriesController(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
public SeriesController(SeriesProvider seriesProvider,
QualityProvider qualityProvider, JobProvider jobProvider,
SeasonProvider seasonProvider)
{
_seriesProvider = seriesProvider;
_episodeProvider = episodeProvider;
_qualityProvider = qualityProvider;
_jobProvider = jobProvider;
_seasonProvider = seasonProvider;
@ -80,9 +78,9 @@ public EmptyResult SaveSingleSeriesEditor(SeriesModel seriesModel)
}
[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();
}

View File

@ -13,21 +13,17 @@ $("#seriesEditor").dialog({
text: "Delete",
class: "ui-delete-button",
click: function () {
var answer = confirm("Are you sure you want to delete this series?");
if (answer) {
var seriesId = $('#SeriesId').val();
$(this).dialog("close");
//Get the SeriesId and Title
var seriesId = $('#SeriesId').val();
var title = $('[aria-labelledby="ui-dialog-title-seriesEditor"]').find('#ui-dialog-title-seriesEditor').text();
$.ajax({
type: "POST",
url: seriesDeleteUrl,
data: { seriesId: seriesId },
success: function (data) {
//Remove the row from the grid... along with the details row
afterDelete();
}
});
$(this).dialog("close");
}
//Fill in the view
$('#seriesDelete').children('.seriesId').val(seriesId);
$('#seriesDelete').children('.seriesTitle').html(title);
$("#seriesDelete").dialog("open");
}
},
"Save": function () {
@ -52,12 +48,12 @@ $("#seriesDelete").dialog({
buttons: {
"Delete": function () {
var seriesId = $('.seriesId').val();
var deleteFiles = $('#DeleteFilesFromDisk').is(':checked');
$.ajax({
type: "POST",
url: seriesDeleteUrl,
data: { seriesId: seriesId },
data: { seriesId: seriesId, deleteFiles: deleteFiles },
success: function (data) {
//Remove the row from the grid... along with the details row
afterDelete(seriesId);
}
});

View File

@ -109,9 +109,16 @@
<div style="visibility: hidden">
<div id="seriesEditor" title="Edit Series">
</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">
<label for="NewQuality">New Quality</label>
@Html.DropDownList("NewQuality", Model.QualitySelectList)

View File

@ -88,9 +88,14 @@
<div style="visibility: hidden">
<div id="seriesEditor" title="Edit Series">
</div>
<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("DeleteFromDisk")
<label for="DeleteFromDisk">Delete all files from disk?</label>
</div>
</div>
</div>
@section Scripts{