Remove empty image folders recursively

This commit is contained in:
Shadowghost 2024-06-07 22:12:48 +02:00
parent b25d6d1e48
commit 28274d4c75
2 changed files with 4 additions and 4 deletions

View File

@ -190,9 +190,9 @@ namespace MediaBrowser.Providers.Manager
// Remove containing directory if empty
var folder = Path.GetDirectoryName(currentPath);
if (!_fileSystem.GetFiles(folder).Any())
if (Directory.Exists(folder) && !_fileSystem.GetFiles(folder, true).Any())
{
Directory.Delete(folder);
Directory.Delete(folder, true);
}
}
catch (FileNotFoundException)

View File

@ -381,9 +381,9 @@ namespace MediaBrowser.Providers.Manager
{
// Always remove empty parent folder
var folder = Path.GetDirectoryName(image.Path);
if (Directory.Exists(folder) && !_fileSystem.GetFiles(folder).Any())
if (Directory.Exists(folder) && !_fileSystem.GetFiles(folder, true).Any())
{
Directory.Delete(folder);
Directory.Delete(folder, true);
}
}
}