1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

Fixing test issue when Linux always returns / for PathGetPathRoot (when its rooted)

http://typedescriptor.net/browse/members/1247454-Mono.Unix.UnixPath.GetPathRoot%28String%29
This commit is contained in:
Mark McDowall 2013-08-08 21:44:49 -07:00
parent 3559d35d92
commit 6b30d831b3
2 changed files with 14 additions and 14 deletions

View File

@ -294,25 +294,25 @@ public long GetAvilableSpace(string path)
{ {
Ensure.That(() => path).IsValidPath(); Ensure.That(() => path).IsValidPath();
if (OsInfo.IsLinux)
{
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && path.StartsWith(c.Name, StringComparison.CurrentCultureIgnoreCase));
if (driveInfo == null)
{
throw new DirectoryNotFoundException(path);
}
return driveInfo.AvailableFreeSpace;
}
var root = GetPathRoot(path); var root = GetPathRoot(path);
if (!FolderExists(root)) if (!FolderExists(root))
throw new DirectoryNotFoundException(root); throw new DirectoryNotFoundException(root);
if (OsInfo.IsLinux)
{
var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && c.Name.Equals(root, StringComparison.CurrentCultureIgnoreCase));
if (driveInfo == null)
{
return 0;
}
return driveInfo.AvailableFreeSpace;
}
return DriveFreeSpaceEx(root); return DriveFreeSpaceEx(root);
} }
private static long DriveFreeSpaceEx(string folderName) private static long DriveFreeSpaceEx(string folderName)
{ {

View File

@ -8,7 +8,7 @@
namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests
{ {
[TestFixture] [TestFixture]
public class FreeDiskSpaceTest : CoreTest<DiskProvider> public class FreeDiskSpaceFixture : CoreTest<DiskProvider>
{ {
[Test] [Test]
public void should_return_free_disk_space() public void should_return_free_disk_space()