Fixed: Recycle Metadata files on episode removal.

This commit is contained in:
Taloth Saldono 2018-03-01 17:09:36 +01:00 committed by Taloth
parent 52588509ed
commit 3573e631c8
3 changed files with 8 additions and 17 deletions

View File

@ -49,8 +49,6 @@ namespace NzbDrone.Core.Extras.Files
_logger = logger; _logger = logger;
} }
public virtual bool PermanentlyDelete => false;
public List<TExtraFile> GetFilesBySeries(int seriesId) public List<TExtraFile> GetFilesBySeries(int seriesId)
{ {
return _repository.GetFilesBySeries(seriesId); return _repository.GetFilesBySeries(seriesId);
@ -122,20 +120,12 @@ namespace NzbDrone.Core.Extras.Files
if (_diskProvider.FileExists(path)) if (_diskProvider.FileExists(path))
{ {
if (PermanentlyDelete) // Send to the recycling bin so they can be recovered if necessary
{
_diskProvider.DeleteFile(path);
}
else
{
// Send extra files to the recycling bin so they can be recovered if necessary
var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path)); var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
_recycleBinProvider.DeleteFile(path, subfolder); _recycleBinProvider.DeleteFile(path, subfolder);
} }
} }
} }
}
_logger.Debug("Deleting Extra from database for episode file: {0}", episodeFile); _logger.Debug("Deleting Extra from database for episode file: {0}", episodeFile);
_repository.DeleteForEpisodeFile(episodeFile.Id); _repository.DeleteForEpisodeFile(episodeFile.Id);

View File

@ -16,7 +16,5 @@ namespace NzbDrone.Core.Extras.Metadata.Files
: base(repository, seriesService, diskProvider, recycleBinProvider, logger) : base(repository, seriesService, diskProvider, recycleBinProvider, logger)
{ {
} }
public override bool PermanentlyDelete => true;
} }
} }

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Extras.Metadata
{ {
private readonly IMetadataFactory _metadataFactory; private readonly IMetadataFactory _metadataFactory;
private readonly ICleanMetadataService _cleanMetadataService; private readonly ICleanMetadataService _cleanMetadataService;
private readonly IRecycleBinProvider _recycleBinProvider;
private readonly IDiskTransferService _diskTransferService; private readonly IDiskTransferService _diskTransferService;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
@ -29,6 +30,7 @@ namespace NzbDrone.Core.Extras.Metadata
public MetadataService(IConfigService configService, public MetadataService(IConfigService configService,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IDiskTransferService diskTransferService, IDiskTransferService diskTransferService,
IRecycleBinProvider recycleBinProvider,
IMetadataFactory metadataFactory, IMetadataFactory metadataFactory,
ICleanMetadataService cleanMetadataService, ICleanMetadataService cleanMetadataService,
IHttpClient httpClient, IHttpClient httpClient,
@ -39,6 +41,7 @@ namespace NzbDrone.Core.Extras.Metadata
{ {
_metadataFactory = metadataFactory; _metadataFactory = metadataFactory;
_cleanMetadataService = cleanMetadataService; _cleanMetadataService = cleanMetadataService;
_recycleBinProvider = recycleBinProvider;
_diskTransferService = diskTransferService; _diskTransferService = diskTransferService;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_httpClient = httpClient; _httpClient = httpClient;
@ -443,11 +446,11 @@ namespace NzbDrone.Core.Extras.Metadata
_logger.Debug("Removing duplicate Metadata file: {0}", path); _logger.Debug("Removing duplicate Metadata file: {0}", path);
_diskProvider.DeleteFile(path); var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
_recycleBinProvider.DeleteFile(path, subfolder);
_metadataFileService.Delete(file.Id); _metadataFileService.Delete(file.Id);
} }
return matchingMetadataFiles.First(); return matchingMetadataFiles.First();
} }
} }