diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 64087ede8..40f4327f4 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -93,6 +93,7 @@
Code
+
diff --git a/NzbDrone.Core.Test/SyncProviderTest.cs b/NzbDrone.Core.Test/SyncProviderTest.cs
new file mode 100644
index 000000000..660f39413
--- /dev/null
+++ b/NzbDrone.Core.Test/SyncProviderTest.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using AutoMoq;
+using Gallio.Framework;
+using MbUnit.Framework;
+using MbUnit.Framework.ContractVerifiers;
+using Moq;
+using NzbDrone.Core.Providers;
+using NzbDrone.Core.Providers.Core;
+using SubSonic.Repository;
+
+namespace NzbDrone.Core.Test
+{
+ [TestFixture]
+ // ReSharper disable InconsistentNaming
+ public class SyncProviderTest
+ {
+ [Test]
+ public void None_existing_folder_returns_empty_list()
+ {
+ string path = "d:\\bad folder";
+
+ var mocker = new AutoMoqer();
+ mocker.GetMock(MockBehavior.Strict)
+ .Setup(m => m.FolderExists(path)).Returns(false);
+
+ var result = mocker.Resolve().GetUnmappedFolders(path);
+
+ Assert.IsNotNull(result);
+ Assert.IsEmpty(result);
+
+ mocker.VerifyAllMocks();
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentException))]
+ public void empty_folder_path_throws()
+ {
+ var mocker = new AutoMoqer();
+ mocker.Resolve().GetUnmappedFolders("");
+ }
+ }
+}
diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs
index 734fccb06..da093bd02 100644
--- a/NzbDrone.Core/Providers/MediaFileProvider.cs
+++ b/NzbDrone.Core/Providers/MediaFileProvider.cs
@@ -30,6 +30,11 @@ namespace NzbDrone.Core.Providers
_episodeProvider = episodeProvider;
}
+ public MediaFileProvider()
+ {
+
+ }
+
///
/// Scans the specified series folder for media files
///
diff --git a/NzbDrone.Core/Providers/SyncProvider.cs b/NzbDrone.Core/Providers/SyncProvider.cs
index c4379e85d..480ea7b22 100644
--- a/NzbDrone.Core/Providers/SyncProvider.cs
+++ b/NzbDrone.Core/Providers/SyncProvider.cs
@@ -41,15 +41,17 @@ namespace NzbDrone.Core.Providers
{
Logger.Debug("Generating list of unmapped folders");
if (String.IsNullOrEmpty(path))
- throw new InvalidOperationException("Invalid path provided");
+ throw new ArgumentException("Invalid path provided", "path");
+
+ var results = new List();
if (!_diskProvider.FolderExists(path))
{
Logger.Debug("Path supplied does not exist: {0}", path);
- return null;
+ return results;
}
- var results = new List();
+
foreach (string seriesFolder in _diskProvider.GetDirectories(path))
{
var cleanPath = Parser.NormalizePath(new DirectoryInfo(seriesFolder).FullName);
diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs
index fedff6a5c..cfb2de05f 100644
--- a/NzbDrone.Web/Global.asax.cs
+++ b/NzbDrone.Web/Global.asax.cs
@@ -1,4 +1,5 @@
using System;
+using System.Data.SQLite;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
@@ -74,11 +75,17 @@ namespace NzbDrone.Web
{
Response.Redirect(Request.ApplicationPath);
}
+ return;
}
- else
+
+ Logger.FatalException(lastError.Message, lastError);
+
+ if (lastError is SQLiteException)
{
- Logger.FatalException(lastError.Message, lastError);
+ Logger.Warn("Restarting application");
+ HttpRuntime.UnloadAppDomain();
}
+
}
protected void Application_BeginRequest()