From 23b2c9eef5062f226a0cb001bc0f3321d97aea41 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 25 Jul 2013 22:22:22 -0700 Subject: [PATCH] more linux fixes --- NzbDrone.Common.Test/PathExtensionFixture.cs | 16 ++++++++-------- NzbDrone.Common/DiskProvider.cs | 2 +- NzbDrone.Common/PathExtensions.cs | 2 +- .../MediaFileTests/MediaFileRepositoryFixture.cs | 4 ++-- .../EpisodeImport/ImportApprovedEpisodes.cs | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/NzbDrone.Common.Test/PathExtensionFixture.cs b/NzbDrone.Common.Test/PathExtensionFixture.cs index e20d15b20..df4e0b575 100644 --- a/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -17,9 +17,9 @@ namespace NzbDrone.Common.Test { var fakeEnvironment = new Mock(); - fakeEnvironment.SetupGet(c => c.AppDataFolder).Returns(@"C:\NzbDrone\"); + fakeEnvironment.SetupGet(c => c.AppDataFolder).Returns(@"C:\NzbDrone\".AsOsAgnostic()); - fakeEnvironment.SetupGet(c => c.TempFolder).Returns(@"C:\Temp\"); + fakeEnvironment.SetupGet(c => c.TempFolder).Returns(@"C:\Temp\".AsOsAgnostic()); return fakeEnvironment.Object; } @@ -33,11 +33,11 @@ namespace NzbDrone.Common.Test [TestCase(@"\\Testserver\Test\file.ext", @"\\Testserver\Test\file.ext")] [TestCase(@"\\Testserver\Test\file.ext\\", @"\\Testserver\Test\file.ext")] [TestCase(@"\\Testserver\Test\file.ext \\", @"\\Testserver\Test\file.ext")] - public void Normalize_Path_Windows(string dirty, string clean) + public void Clean_Path_Windows(string dirty, string clean) { WindowsOnly(); - var result = dirty.CleanPath(); + var result = dirty.CleanFilePath(); result.Should().Be(clean); } @@ -48,18 +48,18 @@ namespace NzbDrone.Common.Test [TestCase(@"//test//other// ", @"/test/other")] [TestCase(@"//test//other//file.ext ", @"/test/other/file.ext")] [TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")] - public void Normalize_Path_Linux(string dirty, string clean) + public void Clean_Path_Linux(string dirty, string clean) { LinuxOnly(); - var result = dirty.CleanPath(); + var result = dirty.CleanFilePath(); result.Should().Be(clean); } [Test] public void normalize_path_exception_empty() { - Assert.Throws(() => "".CleanPath()); + Assert.Throws(() => "".CleanFilePath()); ExceptionVerification.ExpectedWarns(1); } @@ -67,7 +67,7 @@ namespace NzbDrone.Common.Test public void normalize_path_exception_null() { string nullPath = null; - Assert.Throws(() => nullPath.CleanPath()); + Assert.Throws(() => nullPath.CleanFilePath()); ExceptionVerification.ExpectedWarns(1); } diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs index 8de8bd79e..a7aac8b8a 100644 --- a/NzbDrone.Common/DiskProvider.cs +++ b/NzbDrone.Common/DiskProvider.cs @@ -346,7 +346,7 @@ namespace NzbDrone.Common Ensure.That(() => firstPath).IsValidPath(); Ensure.That(() => secondPath).IsValidPath(); - return String.Equals(firstPath.CleanPath(), secondPath.CleanPath(), StringComparison.InvariantCultureIgnoreCase); + return String.Equals(firstPath.CleanFilePath(), secondPath.CleanFilePath(), StringComparison.InvariantCultureIgnoreCase); } public virtual void FileSetLastWriteTimeUtc(string path, DateTime dateTime) diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs index dfe2149dc..c555e7426 100644 --- a/NzbDrone.Common/PathExtensions.cs +++ b/NzbDrone.Common/PathExtensions.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Common private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar; private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar; - public static string CleanPath(this string path) + public static string CleanFilePath(this string path) { Ensure.That(() => path).IsNotNullOrWhiteSpace(); diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs index 68e7522a3..4bc76ee62 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs @@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test.MediaFileTests var episodeFile = Builder.CreateNew() .With(f => f.Id = 0) - .With(f => f.Path = path.CleanPath()) + .With(f => f.Path = path.CleanFilePath()) .Build(); Subject.Insert(episodeFile); @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.MediaFileTests //Resolve file.Should().NotBeNull(); - file.Path.Should().Be(path.CleanPath()); + file.Path.Should().Be(path.CleanFilePath()); } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs index e74a27ac5..0757b1495 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedEpisodes.cs @@ -58,11 +58,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport var episodeFile = new EpisodeFile(); episodeFile.DateAdded = DateTime.UtcNow; episodeFile.SeriesId = localEpisode.Series.Id; - episodeFile.Path = localEpisode.Path.CleanPath(); + episodeFile.Path = localEpisode.Path.CleanFilePath(); episodeFile.Size = _diskProvider.GetFileSize(localEpisode.Path); episodeFile.Quality = localEpisode.Quality; episodeFile.SeasonNumber = localEpisode.SeasonNumber; - episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanPath()); + episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath()); episodeFile.Episodes = localEpisode.Episodes; if (newDownload)