From bb1f6649b54ffdc6d191301041c2b14e1c02d1c0 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Wed, 2 Nov 2011 19:09:00 -0700 Subject: [PATCH] Fixed application path issue. --- NzbDrone.Common.Test/EnviromentProviderTest.cs | 9 ++++++++- NzbDrone.Common/EnviromentProvider.cs | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Common.Test/EnviromentProviderTest.cs b/NzbDrone.Common.Test/EnviromentProviderTest.cs index 2ccb51841..b4d7d6c3d 100644 --- a/NzbDrone.Common.Test/EnviromentProviderTest.cs +++ b/NzbDrone.Common.Test/EnviromentProviderTest.cs @@ -12,7 +12,6 @@ namespace NzbDrone.Common.Test readonly EnviromentProvider enviromentController = new EnviromentProvider(); [Test] - public void Is_user_interactive_should_be_false() { enviromentController.IsUserInteractive.Should().BeTrue(); @@ -41,6 +40,14 @@ namespace NzbDrone.Common.Test Path.IsPathRooted(enviromentController.ApplicationPath).Should().BeTrue("Path is not rooted"); } + + [Test] + public void ApplicationPath_should_find_iis_in_current_folder() + { + Directory.CreateDirectory(EnviromentProvider.IIS_FOLDER_NAME); + enviromentController.ApplicationPath.Should().BeEquivalentTo(Directory.GetCurrentDirectory()); + } + [Test] public void IsProduction_should_return_false_when_run_within_nunit() { diff --git a/NzbDrone.Common/EnviromentProvider.cs b/NzbDrone.Common/EnviromentProvider.cs index 6b73c980d..fe7b78451 100644 --- a/NzbDrone.Common/EnviromentProvider.cs +++ b/NzbDrone.Common/EnviromentProvider.cs @@ -7,6 +7,7 @@ namespace NzbDrone.Common { public class EnviromentProvider { + public const string IIS_FOLDER_NAME = "iisexpress"; #if DEBUG private static readonly bool isInDebug = true; @@ -45,7 +46,7 @@ namespace NzbDrone.Common { get { - var dir = new FileInfo(Environment.CurrentDirectory).Directory; + var dir = new DirectoryInfo(Environment.CurrentDirectory); while (!ContainsIIS(dir)) { @@ -79,7 +80,7 @@ namespace NzbDrone.Common { get { - var path = Path.Combine(WebRoot, "App_data"); + var path = Path.Combine(WebRoot, "App_Data"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); @@ -121,7 +122,7 @@ namespace NzbDrone.Common private static bool ContainsIIS(DirectoryInfo dir) { - return dir.GetDirectories("iisexpress").Length != 0; + return dir.GetDirectories(IIS_FOLDER_NAME).Length != 0; } } } \ No newline at end of file