mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 12:32:31 +01:00
more linux fixes
This commit is contained in:
parent
ea195afc87
commit
23b2c9eef5
@ -17,9 +17,9 @@ private IAppFolderInfo GetIAppDirectoryInfo()
|
|||||||
{
|
{
|
||||||
var fakeEnvironment = new Mock<IAppFolderInfo>();
|
var fakeEnvironment = new Mock<IAppFolderInfo>();
|
||||||
|
|
||||||
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;
|
return fakeEnvironment.Object;
|
||||||
}
|
}
|
||||||
@ -33,11 +33,11 @@ private IAppFolderInfo GetIAppDirectoryInfo()
|
|||||||
[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")]
|
[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();
|
WindowsOnly();
|
||||||
|
|
||||||
var result = dirty.CleanPath();
|
var result = dirty.CleanFilePath();
|
||||||
result.Should().Be(clean);
|
result.Should().Be(clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,18 +48,18 @@ public void Normalize_Path_Windows(string dirty, string clean)
|
|||||||
[TestCase(@"//test//other// ", @"/test/other")]
|
[TestCase(@"//test//other// ", @"/test/other")]
|
||||||
[TestCase(@"//test//other//file.ext ", @"/test/other/file.ext")]
|
[TestCase(@"//test//other//file.ext ", @"/test/other/file.ext")]
|
||||||
[TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")]
|
[TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")]
|
||||||
public void Normalize_Path_Linux(string dirty, string clean)
|
public void Clean_Path_Linux(string dirty, string clean)
|
||||||
{
|
{
|
||||||
LinuxOnly();
|
LinuxOnly();
|
||||||
|
|
||||||
var result = dirty.CleanPath();
|
var result = dirty.CleanFilePath();
|
||||||
result.Should().Be(clean);
|
result.Should().Be(clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void normalize_path_exception_empty()
|
public void normalize_path_exception_empty()
|
||||||
{
|
{
|
||||||
Assert.Throws<ArgumentException>(() => "".CleanPath());
|
Assert.Throws<ArgumentException>(() => "".CleanFilePath());
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public void normalize_path_exception_empty()
|
|||||||
public void normalize_path_exception_null()
|
public void normalize_path_exception_null()
|
||||||
{
|
{
|
||||||
string nullPath = null;
|
string nullPath = null;
|
||||||
Assert.Throws<ArgumentException>(() => nullPath.CleanPath());
|
Assert.Throws<ArgumentException>(() => nullPath.CleanFilePath());
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ public static bool PathEquals(string firstPath, string secondPath)
|
|||||||
Ensure.That(() => firstPath).IsValidPath();
|
Ensure.That(() => firstPath).IsValidPath();
|
||||||
Ensure.That(() => secondPath).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)
|
public virtual void FileSetLastWriteTimeUtc(string path, DateTime dateTime)
|
||||||
|
@ -19,7 +19,7 @@ public static class PathExtensions
|
|||||||
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
|
||||||
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + 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();
|
Ensure.That(() => path).IsNotNullOrWhiteSpace();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
|
|||||||
|
|
||||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||||
.With(f => f.Id = 0)
|
.With(f => f.Id = 0)
|
||||||
.With(f => f.Path = path.CleanPath())
|
.With(f => f.Path = path.CleanFilePath())
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Subject.Insert(episodeFile);
|
Subject.Insert(episodeFile);
|
||||||
@ -62,7 +62,7 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
|
|||||||
|
|
||||||
//Resolve
|
//Resolve
|
||||||
file.Should().NotBeNull();
|
file.Should().NotBeNull();
|
||||||
file.Path.Should().Be(path.CleanPath());
|
file.Path.Should().Be(path.CleanFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,11 +58,11 @@ public List<ImportDecision> Import(List<ImportDecision> decisions, bool newDownl
|
|||||||
var episodeFile = new EpisodeFile();
|
var episodeFile = new EpisodeFile();
|
||||||
episodeFile.DateAdded = DateTime.UtcNow;
|
episodeFile.DateAdded = DateTime.UtcNow;
|
||||||
episodeFile.SeriesId = localEpisode.Series.Id;
|
episodeFile.SeriesId = localEpisode.Series.Id;
|
||||||
episodeFile.Path = localEpisode.Path.CleanPath();
|
episodeFile.Path = localEpisode.Path.CleanFilePath();
|
||||||
episodeFile.Size = _diskProvider.GetFileSize(localEpisode.Path);
|
episodeFile.Size = _diskProvider.GetFileSize(localEpisode.Path);
|
||||||
episodeFile.Quality = localEpisode.Quality;
|
episodeFile.Quality = localEpisode.Quality;
|
||||||
episodeFile.SeasonNumber = localEpisode.SeasonNumber;
|
episodeFile.SeasonNumber = localEpisode.SeasonNumber;
|
||||||
episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanPath());
|
episodeFile.SceneName = Path.GetFileNameWithoutExtension(localEpisode.Path.CleanFilePath());
|
||||||
episodeFile.Episodes = localEpisode.Episodes;
|
episodeFile.Episodes = localEpisode.Episodes;
|
||||||
|
|
||||||
if (newDownload)
|
if (newDownload)
|
||||||
|
Loading…
Reference in New Issue
Block a user