1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-25 17:27:59 +00:00

New: Move subtitles/other extra files to Sonarr's Recycle Bin instead of permanently deleting

This commit is contained in:
Mark McDowall 2016-11-02 11:11:55 -07:00
parent d3890bd712
commit db899a9bb8
4 changed files with 39 additions and 7 deletions

View file

@ -4,6 +4,7 @@
using System.Linq;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
@ -31,19 +32,30 @@ public abstract class ExtraFileService<TExtraFile> : IExtraFileService<TExtraFil
private readonly IExtraFileRepository<TExtraFile> _repository;
private readonly ISeriesService _seriesService;
private readonly IDiskProvider _diskProvider;
private readonly IRecycleBinProvider _recycleBinProvider;
private readonly Logger _logger;
public ExtraFileService(IExtraFileRepository<TExtraFile> repository,
ISeriesService seriesService,
IDiskProvider diskProvider,
IRecycleBinProvider recycleBinProvider,
Logger logger)
{
_repository = repository;
_seriesService = seriesService;
_diskProvider = diskProvider;
_recycleBinProvider = recycleBinProvider;
_logger = logger;
}
public virtual bool PermanentlyDelete
{
get
{
return false;
}
}
public List<TExtraFile> GetFilesBySeries(int seriesId)
{
return _repository.GetFilesBySeries(seriesId);
@ -107,7 +119,16 @@ public void HandleAsync(EpisodeFileDeletedEvent message)
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);
}
}
}

View file

@ -1,6 +1,7 @@
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Extras.Metadata.Files
@ -11,9 +12,17 @@ public interface IMetadataFileService : IExtraFileService<MetadataFile>
public class MetadataFileService : ExtraFileService<MetadataFile>, IMetadataFileService
{
public MetadataFileService(IExtraFileRepository<MetadataFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
: base(repository, seriesService, diskProvider, logger)
public MetadataFileService(IExtraFileRepository<MetadataFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
{
}
public override bool PermanentlyDelete
{
get
{
return true;
}
}
}
}

View file

@ -1,6 +1,7 @@
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Extras.Others
@ -11,8 +12,8 @@ public interface IOtherExtraFileService : IExtraFileService<OtherExtraFile>
public class OtherExtraFileService : ExtraFileService<OtherExtraFile>, IOtherExtraFileService
{
public OtherExtraFileService(IExtraFileRepository<OtherExtraFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
: base(repository, seriesService, diskProvider, logger)
public OtherExtraFileService(IExtraFileRepository<OtherExtraFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
{
}
}

View file

@ -1,6 +1,7 @@
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Extras.Files;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Extras.Subtitles
@ -11,8 +12,8 @@ public interface ISubtitleFileService : IExtraFileService<SubtitleFile>
public class SubtitleFileService : ExtraFileService<SubtitleFile>, ISubtitleFileService
{
public SubtitleFileService(IExtraFileRepository<SubtitleFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, Logger logger)
: base(repository, seriesService, diskProvider, logger)
public SubtitleFileService(IExtraFileRepository<SubtitleFile> repository, ISeriesService seriesService, IDiskProvider diskProvider, IRecycleBinProvider recycleBinProvider, Logger logger)
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
{
}
}