From aee31d1bc200f823f8148edaa6bc405e8d58398a Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 25 Jul 2013 23:25:03 -0700 Subject: [PATCH] more linux fixes --- NzbDrone.Common.Test/PathExtensionFixture.cs | 25 ++++++++++++++++---- NzbDrone.Common/PathExtensions.cs | 3 ++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/NzbDrone.Common.Test/PathExtensionFixture.cs b/NzbDrone.Common.Test/PathExtensionFixture.cs index 35b05ac66..3e66e4773 100644 --- a/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -79,7 +79,7 @@ namespace NzbDrone.Common.Test } [Test] - public void get_actual_casing_should_return_actual_casing_for_local_file() + public void get_actual_casing_should_return_actual_casing_for_local_file_in_windows() { var path = Process.GetCurrentProcess().MainModule.FileName; path.ToUpper().GetActualCasing().Should().Be(path); @@ -87,14 +87,32 @@ namespace NzbDrone.Common.Test } [Test] - public void get_actual_casing_should_return_actual_casing_for_local_dir() + public void get_actual_casing_should_return_origibal_value_in_linux() { + var path = Process.GetCurrentProcess().MainModule.FileName; + path.GetActualCasing().Should().Be(path); + path.GetActualCasing().Should().Be(path); + } + + [Test] + public void get_actual_casing_should_return_actual_casing_for_local_dir_in_windows() + { + WindowsOnly(); var path = Directory.GetCurrentDirectory(); path.ToUpper().GetActualCasing().Should().Be(path); path.ToLower().GetActualCasing().Should().Be(path); } + [Test] + public void get_actual_casing_should_return_original_value_in_linux() + { + WindowsOnly(); + var path = Directory.GetCurrentDirectory(); + path.GetActualCasing().Should().Be(path); + path.GetActualCasing().Should().Be(path); + } + [Test] [Explicit] public void get_actual_casing_should_return_original_casing_for_shares() @@ -103,9 +121,6 @@ namespace NzbDrone.Common.Test path.GetActualCasing().Should().Be(path); } - - - [Test] public void AppDataDirectory_path_test() { diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs index 7b56faa37..85c852e60 100644 --- a/NzbDrone.Common/PathExtensions.cs +++ b/NzbDrone.Common/PathExtensions.cs @@ -22,8 +22,9 @@ namespace NzbDrone.Common public static string CleanFilePath(this string path) { Ensure.That(() => path).IsNotNullOrWhiteSpace(); + Ensure.That(() => path).IsValidPath(); - var info = new FileInfo(path); + var info = new FileInfo(path.Trim()); if (!OsInfo.IsLinux && info.FullName.StartsWith(@"\\")) //UNC {