mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fixed: Deleting empty folders on upgrade
Fixes #4787 Fixes SENTRY RADARR-1F
This commit is contained in:
parent
695297435e
commit
ec15885680
@ -122,23 +122,27 @@ public void HandleAsync(MoviesDeletedEvent message)
|
|||||||
[EventHandleOrder(EventHandleOrder.Last)]
|
[EventHandleOrder(EventHandleOrder.Last)]
|
||||||
public void Handle(MovieFileDeletedEvent message)
|
public void Handle(MovieFileDeletedEvent message)
|
||||||
{
|
{
|
||||||
if (message.Reason == DeleteMediaFileReason.Upgrade)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_configService.DeleteEmptyFolders)
|
if (_configService.DeleteEmptyFolders)
|
||||||
{
|
{
|
||||||
var movie = message.MovieFile.Movie;
|
var movie = message.MovieFile.Movie;
|
||||||
var movieFileFolder = message.MovieFile.Path.GetParentPath();
|
var moviePath = movie.Path;
|
||||||
|
var folder = message.MovieFile.Path.GetParentPath();
|
||||||
|
|
||||||
if (_diskProvider.GetFiles(movie.Path, SearchOption.AllDirectories).Empty())
|
while (moviePath.IsParentPath(folder))
|
||||||
{
|
{
|
||||||
_diskProvider.DeleteFolder(movie.Path, true);
|
if (_diskProvider.FolderExists(folder))
|
||||||
|
{
|
||||||
|
_diskProvider.RemoveEmptySubfolders(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
folder = folder.GetParentPath();
|
||||||
}
|
}
|
||||||
else if (_diskProvider.GetFiles(movieFileFolder, SearchOption.AllDirectories).Empty())
|
|
||||||
|
_diskProvider.RemoveEmptySubfolders(moviePath);
|
||||||
|
|
||||||
|
if (_diskProvider.FolderEmpty(moviePath))
|
||||||
{
|
{
|
||||||
_diskProvider.RemoveEmptySubfolders(movieFileFolder);
|
_diskProvider.DeleteFolder(moviePath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user