From 6b30d831b3a16562e81b2e753b6caf759fbe9a6d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 8 Aug 2013 21:44:49 -0700 Subject: [PATCH] Fixing test issue when Linux always returns / for PathGetPathRoot (when its rooted) http://typedescriptor.net/browse/members/1247454-Mono.Unix.UnixPath.GetPathRoot%28String%29 --- NzbDrone.Common/DiskProvider.cs | 18 +++++++++--------- ...iskSpaceTest.cs => FreeDiskSpaceFixture.cs} | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) rename NzbDrone.Core.Test/ProviderTests/DiskProviderTests/{FreeDiskSpaceTest.cs => FreeDiskSpaceFixture.cs} (94%) diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs index cb15a672f..cf88f96f3 100644 --- a/NzbDrone.Common/DiskProvider.cs +++ b/NzbDrone.Common/DiskProvider.cs @@ -294,25 +294,25 @@ namespace NzbDrone.Common { Ensure.That(() => path).IsValidPath(); - var root = GetPathRoot(path); - - if (!FolderExists(root)) - throw new DirectoryNotFoundException(root); - if (OsInfo.IsLinux) { - var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && c.Name.Equals(root, StringComparison.CurrentCultureIgnoreCase)); + var driveInfo = DriveInfo.GetDrives().SingleOrDefault(c => c.IsReady && path.StartsWith(c.Name, StringComparison.CurrentCultureIgnoreCase)); if (driveInfo == null) { - return 0; + throw new DirectoryNotFoundException(path); } - return driveInfo.AvailableFreeSpace; + return driveInfo.AvailableFreeSpace; } + var root = GetPathRoot(path); + + if (!FolderExists(root)) + throw new DirectoryNotFoundException(root); + return DriveFreeSpaceEx(root); - } + } private static long DriveFreeSpaceEx(string folderName) { diff --git a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceFixture.cs similarity index 94% rename from NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs rename to NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceFixture.cs index 9ae177c51..aa6d29a73 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceFixture.cs @@ -8,7 +8,7 @@ using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests { [TestFixture] - public class FreeDiskSpaceTest : CoreTest + public class FreeDiskSpaceFixture : CoreTest { [Test] public void should_return_free_disk_space()