|
|
@ -129,28 +129,30 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
[EventHandleOrder(EventHandleOrder.Last)]
|
|
|
|
[EventHandleOrder(EventHandleOrder.Last)]
|
|
|
|
public void Handle(EpisodeFileDeletedEvent message)
|
|
|
|
public void Handle(EpisodeFileDeletedEvent message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_configService.DeleteEmptyFolders)
|
|
|
|
if (!_configService.DeleteEmptyFolders || message.Reason == DeleteMediaFileReason.MissingFromDisk)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var series = message.EpisodeFile.Series.Value;
|
|
|
|
return;
|
|
|
|
var seriesPath = series.Path;
|
|
|
|
}
|
|
|
|
var folder = message.EpisodeFile.Path.GetParentPath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (seriesPath.IsParentPath(folder))
|
|
|
|
var series = message.EpisodeFile.Series.Value;
|
|
|
|
{
|
|
|
|
var seriesPath = series.Path;
|
|
|
|
if (_diskProvider.FolderExists(folder))
|
|
|
|
var folder = message.EpisodeFile.Path.GetParentPath();
|
|
|
|
{
|
|
|
|
|
|
|
|
_diskProvider.RemoveEmptySubfolders(folder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
folder = folder.GetParentPath();
|
|
|
|
while (seriesPath.IsParentPath(folder))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_diskProvider.FolderExists(folder))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_diskProvider.RemoveEmptySubfolders(folder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_diskProvider.RemoveEmptySubfolders(seriesPath);
|
|
|
|
folder = folder.GetParentPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_diskProvider.FolderEmpty(seriesPath))
|
|
|
|
_diskProvider.RemoveEmptySubfolders(seriesPath);
|
|
|
|
{
|
|
|
|
|
|
|
|
_diskProvider.DeleteFolder(seriesPath, true);
|
|
|
|
if (_diskProvider.FolderEmpty(seriesPath))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
_diskProvider.DeleteFolder(seriesPath, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|