|
|
|
@ -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 @@ namespace NzbDrone.Core.Jobs
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|