|
|
@ -154,6 +154,13 @@ namespace NzbDrone.Common.Disk
|
|
|
|
return _fileSystem.Directory.GetDirectories(path);
|
|
|
|
return _fileSystem.Directory.GetDirectories(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string[] GetDirectories(string path, SearchOption searchOption)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Ensure.That(path, () => path).IsValidPath();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _fileSystem.Directory.GetDirectories(path, "*", searchOption);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string[] GetFiles(string path, SearchOption searchOption)
|
|
|
|
public string[] GetFiles(string path, SearchOption searchOption)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Ensure.That(path, () => path).IsValidPath();
|
|
|
|
Ensure.That(path, () => path).IsValidPath();
|
|
|
@ -500,10 +507,11 @@ namespace NzbDrone.Common.Disk
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveEmptySubfolders(string path)
|
|
|
|
public void RemoveEmptySubfolders(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var subfolders = GetDirectories(path);
|
|
|
|
var subfolders = GetDirectories(path, SearchOption.AllDirectories);
|
|
|
|
var files = GetFiles(path, SearchOption.AllDirectories);
|
|
|
|
var files = GetFiles(path, SearchOption.AllDirectories);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var subfolder in subfolders)
|
|
|
|
// By sorting by length descending we ensure we always delete children before parents
|
|
|
|
|
|
|
|
foreach (var subfolder in subfolders.OrderByDescending(x => x.Length))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (files.None(f => subfolder.IsParentPath(f)))
|
|
|
|
if (files.None(f => subfolder.IsParentPath(f)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|