1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 01:38:24 +00:00

Fixed: Don't delete extra files after unlinking an episode file that still exists on disk

This commit is contained in:
Mark McDowall 2016-11-23 16:38:40 -08:00
parent b093be3f4e
commit 7b09b259a8
2 changed files with 21 additions and 12 deletions

View file

@ -111,23 +111,32 @@ public void HandleAsync(SeriesDeletedEvent message)
public void HandleAsync(EpisodeFileDeletedEvent message) public void HandleAsync(EpisodeFileDeletedEvent message)
{ {
var episodeFile = message.EpisodeFile; var episodeFile = message.EpisodeFile;
var series = _seriesService.GetSeries(message.EpisodeFile.SeriesId);
foreach (var extra in _repository.GetFilesByEpisodeFile(episodeFile.Id)) if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
{ {
var path = Path.Combine(series.Path, extra.RelativePath); _logger.Debug("Removing episode file from DB as part of cleanup routine, not deleting extra files from disk.");
}
if (_diskProvider.FileExists(path)) else
{
var series = _seriesService.GetSeries(message.EpisodeFile.SeriesId);
foreach (var extra in _repository.GetFilesByEpisodeFile(episodeFile.Id))
{ {
if (PermanentlyDelete) var path = Path.Combine(series.Path, extra.RelativePath);
{
_diskProvider.DeleteFile(path);
}
else if (_diskProvider.FileExists(path))
{ {
// Send extra files to the recycling bin so they can be recovered if necessary if (PermanentlyDelete)
_recycleBinProvider.DeleteFile(path); {
_diskProvider.DeleteFile(path);
}
else
{
// Send extra files to the recycling bin so they can be recovered if necessary
_recycleBinProvider.DeleteFile(path);
}
} }
} }
} }

View file

@ -236,7 +236,7 @@ public void Handle(EpisodeFileDeletedEvent message)
{ {
if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes) if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
{ {
_logger.Debug("Removing episode file from DB as part of cleanup routine."); _logger.Debug("Removing episode file from DB as part of cleanup routine, not creating history event.");
return; return;
} }