mirror of
https://github.com/Sonarr/Sonarr
synced 2025-03-03 18:26:42 +00:00
RootDirProvider.GetMostFreeRootDir() will calculate the find the RootDir with the most free space and return its path.
This commit is contained in:
parent
117cebe655
commit
b3abcb6096
2 changed files with 23 additions and 0 deletions
|
@ -83,6 +83,26 @@ namespace NzbDrone.Core.Providers
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string GetMostFreeRootDir()
|
||||||
|
{
|
||||||
|
ulong maxSize = 0;
|
||||||
|
var maxPath = String.Empty;
|
||||||
|
|
||||||
|
var rootDirs = GetAll();
|
||||||
|
|
||||||
|
foreach (var rootDir in rootDirs)
|
||||||
|
{
|
||||||
|
rootDir.FreeSpace = new DirectoryInfo(rootDir.Path).FreeDiskSpace();
|
||||||
|
if (rootDir.FreeSpace > maxSize)
|
||||||
|
{
|
||||||
|
maxPath = rootDir.Path;
|
||||||
|
maxSize = rootDir.FreeSpace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxPath;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,5 +9,8 @@ namespace NzbDrone.Core.Repository
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
|
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
[ResultColumn]
|
||||||
|
public ulong FreeSpace { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue