diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs
index afb5f5a65..53ceacebf 100644
--- a/NzbDrone.Common/DiskProvider.cs
+++ b/NzbDrone.Common/DiskProvider.cs
@@ -193,8 +193,8 @@ namespace NzbDrone.Common
public virtual ulong FreeDiskSpace(DirectoryInfo directoryInfo)
{
- if (!directoryInfo.Exists)
- throw new DirectoryNotFoundException();
+ if(!directoryInfo.Exists)
+ throw new DirectoryNotFoundException(directoryInfo.FullName);
ulong freeBytesAvailable;
ulong totalNumberOfBytes;
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 695ff349b..078ff485b 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -142,6 +142,7 @@
+
@@ -237,7 +238,7 @@
-
+
diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs
new file mode 100644
index 000000000..a508355be
--- /dev/null
+++ b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs
@@ -0,0 +1,114 @@
+// ReSharper disable RedundantUsingDirective
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+using FluentAssertions;
+using Moq;
+using NUnit.Framework;
+using NzbDrone.Common;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Core;
+using NzbDrone.Core.Repository;
+using NzbDrone.Core.Test.Framework;
+using NzbDrone.Test.Common;
+using NzbDrone.Test.Common.AutoMoq;
+using PetaPoco;
+
+namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
+{
+ [TestFixture]
+ // ReSharper disable InconsistentNaming
+ public class FreeSpaceOnDrivesFixture : CoreTest
+ {
+ [Test]
+ public void should_return_one_drive_when_only_one_root_dir_exists()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.Fetch())
+ .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" } });
+
+ Mocker.GetMock()
+ .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
+ .Returns(@"C:\");
+
+ Mocker.GetMock()
+ .Setup(s => s.FreeDiskSpace(new DirectoryInfo(@"C:\")))
+ .Returns(123456);
+
+ var result = Mocker.Resolve().FreeSpaceOnDrives();
+
+ result.Should().HaveCount(1);
+ }
+
+ [Test]
+ public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.Fetch())
+ .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" },
+ new RootDir { Id = 2, Path = @"C:\Test\TV2" }});
+
+ Mocker.GetMock()
+ .Setup(s => s.GetPathRoot(It.IsAny()))
+ .Returns(@"C:\");
+
+ Mocker.GetMock()
+ .Setup(s => s.FreeDiskSpace(new DirectoryInfo(@"C:\")))
+ .Returns(123456);
+
+ var result = Mocker.Resolve().FreeSpaceOnDrives();
+
+ result.Should().HaveCount(1);
+ }
+
+ [Test]
+ public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.Fetch())
+ .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" },
+ new RootDir { Id = 2, Path = @"D:\Test\TV" }});
+
+ Mocker.GetMock()
+ .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
+ .Returns(@"C:\");
+
+ Mocker.GetMock()
+ .Setup(s => s.GetPathRoot(@"D:\Test\TV"))
+ .Returns(@"D:\");
+
+ Mocker.GetMock()
+ .Setup(s => s.FreeDiskSpace(It.IsAny()))
+ .Returns(123456);
+
+ var result = Mocker.Resolve().FreeSpaceOnDrives();
+
+ result.Should().HaveCount(2);
+ }
+
+ [Test]
+ public void should_skip_rootDir_if_not_found_on_disk()
+ {
+ Mocker.GetMock()
+ .Setup(s => s.Fetch())
+ .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" } });
+
+ Mocker.GetMock()
+ .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
+ .Returns(@"C:\");
+
+ Mocker.GetMock()
+ .Setup(s => s.FreeDiskSpace(It.IsAny()))
+ .Throws(new DirectoryNotFoundException());
+
+ var result = Mocker.Resolve().FreeSpaceOnDrives();
+
+ result.Should().HaveCount(0);
+
+ ExceptionVerification.ExpectedWarns(1);
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs
similarity index 97%
rename from NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs
index 433155a40..4d1da14d2 100644
--- a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs
@@ -14,11 +14,11 @@ using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
-namespace NzbDrone.Core.Test.ProviderTests
+namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class RootDirProviderTest : CoreTest
+ public class RootDirProviderFixture : CoreTest
{
[SetUp]
public void Setup()
@@ -35,7 +35,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.Returns(false);
}
-
[Test]
public void GetRootDir_should_return_all_existing_roots()
{
@@ -48,7 +47,6 @@ namespace NzbDrone.Core.Test.ProviderTests
result.Should().HaveCount(2);
}
-
[TestCase("D:\\TV Shows\\")]
[TestCase("//server//folder")]
public void should_be_able_to_add_root_dir(string path)
@@ -74,7 +72,6 @@ namespace NzbDrone.Core.Test.ProviderTests
Assert.Throws(() => rootDirProvider.Add(new RootDir { Path = "C:\\TEST" }));
}
-
[Test]
public void should_be_able_to_remove_root_dir()
{
@@ -91,7 +88,6 @@ namespace NzbDrone.Core.Test.ProviderTests
rootDirs.Should().HaveCount(1);
}
-
[Test]
public void None_existing_folder_returns_empty_list()
{
@@ -132,6 +128,5 @@ namespace NzbDrone.Core.Test.ProviderTests
rootDirProvider.Add(new RootDir { Path = @"C:\TV" });
Assert.Throws(() => rootDirProvider.Add(new RootDir { Path = @"C:\TV" }));
}
-
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs
index 6dba0ee00..0e22e0f14 100644
--- a/NzbDrone.Core/Providers/RootDirProvider.cs
+++ b/NzbDrone.Core/Providers/RootDirProvider.cs
@@ -98,8 +98,17 @@ namespace NzbDrone.Core.Providers
{
var pathRoot = _diskProvider.GetPathRoot(rootDir.Path);
- if (!freeSpace.ContainsKey(pathRoot))
- freeSpace.Add(pathRoot, _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path)));
+ if(!freeSpace.ContainsKey(pathRoot))
+ {
+ try
+ {
+ freeSpace.Add(pathRoot, _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path)));
+ }
+ catch(Exception ex)
+ {
+ Logger.WarnException("Error getting fromm space for: " + pathRoot, ex);
+ }
+ }
}
return freeSpace;