New: Move subtitles/other extra files to Sonarr's Recycle Bin instead of permanently deleting
This commit is contained in:
parent
d3890bd712
commit
db899a9bb8
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
@ -31,19 +32,30 @@ namespace NzbDrone.Core.Extras.Files
|
||||||
private readonly IExtraFileRepository<TExtraFile> _repository;
|
private readonly IExtraFileRepository<TExtraFile> _repository;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
private readonly IRecycleBinProvider _recycleBinProvider;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ExtraFileService(IExtraFileRepository<TExtraFile> repository,
|
public ExtraFileService(IExtraFileRepository<TExtraFile> repository,
|
||||||
ISeriesService seriesService,
|
ISeriesService seriesService,
|
||||||
IDiskProvider diskProvider,
|
IDiskProvider diskProvider,
|
||||||
|
IRecycleBinProvider recycleBinProvider,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_seriesService = seriesService;
|
_seriesService = seriesService;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
|
_recycleBinProvider = recycleBinProvider;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool PermanentlyDelete
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<TExtraFile> GetFilesBySeries(int seriesId)
|
public List<TExtraFile> GetFilesBySeries(int seriesId)
|
||||||
{
|
{
|
||||||
return _repository.GetFilesBySeries(seriesId);
|
return _repository.GetFilesBySeries(seriesId);
|
||||||
|
@ -107,7 +119,16 @@ namespace NzbDrone.Core.Extras.Files
|
||||||
|
|
||||||
if (_diskProvider.FileExists(path))
|
if (_diskProvider.FileExists(path))
|
||||||
{
|
{
|
||||||
_diskProvider.DeleteFile(path);
|
if (PermanentlyDelete)
|
||||||
|
{
|
||||||
|
_diskProvider.DeleteFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Send extra files to the recycling bin so they can be recovered if necessary
|
||||||
|
_recycleBinProvider.DeleteFile(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Extras.Files;
|
using NzbDrone.Core.Extras.Files;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Extras.Metadata.Files
|
namespace NzbDrone.Core.Extras.Metadata.Files
|
||||||
|
@ -11,9 +12,17 @@ namespace NzbDrone.Core.Extras.Metadata.Files
|
||||||
|
|
||||||
public class MetadataFileService : ExtraFileService<MetadataFile>, IMetadataFileService
|
public class MetadataFileService : ExtraFileService<MetadataFile>, IMetadataFileService
|
||||||
{
|
{
|
||||||
public MetadataFileService(IExtraFileRepository<MetadataFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
|
public MetadataFileService(IExtraFileRepository<MetadataFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
|
||||||
: base(repository, seriesService, diskProvider, logger)
|
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool PermanentlyDelete
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Extras.Files;
|
using NzbDrone.Core.Extras.Files;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Extras.Others
|
namespace NzbDrone.Core.Extras.Others
|
||||||
|
@ -11,8 +12,8 @@ namespace NzbDrone.Core.Extras.Others
|
||||||
|
|
||||||
public class OtherExtraFileService : ExtraFileService<OtherExtraFile>, IOtherExtraFileService
|
public class OtherExtraFileService : ExtraFileService<OtherExtraFile>, IOtherExtraFileService
|
||||||
{
|
{
|
||||||
public OtherExtraFileService(IExtraFileRepository<OtherExtraFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
|
public OtherExtraFileService(IExtraFileRepository<OtherExtraFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
|
||||||
: base(repository, seriesService, diskProvider, logger)
|
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.Extras.Files;
|
using NzbDrone.Core.Extras.Files;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Extras.Subtitles
|
namespace NzbDrone.Core.Extras.Subtitles
|
||||||
|
@ -11,8 +12,8 @@ namespace NzbDrone.Core.Extras.Subtitles
|
||||||
|
|
||||||
public class SubtitleFileService : ExtraFileService<SubtitleFile>, ISubtitleFileService
|
public class SubtitleFileService : ExtraFileService<SubtitleFile>, ISubtitleFileService
|
||||||
{
|
{
|
||||||
public SubtitleFileService(IExtraFileRepository<SubtitleFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
|
public SubtitleFileService(IExtraFileRepository<SubtitleFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
|
||||||
: base(repository, seriesService, diskProvider, logger)
|
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue