1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-10 11:10:40 +02:00

Fixed some issue around path normalization.

This commit is contained in:
kay.one 2011-12-10 11:22:47 -08:00
parent e269494ff8
commit bfe4de7a08
7 changed files with 32 additions and 10 deletions

View File

@ -94,6 +94,26 @@ public void MoveFolder_should_overright_existing_folder()
VerifyMove();
}
[TestCase(@"C:\", @"C:\")]
[TestCase(@"C:\\", @"C:\")]
[TestCase(@"c:\", @"C:\")]
[TestCase(@"c:\Test", @"C:\Test\\")]
[TestCase(@"c:\\\\\Test", @"C:\Test\\")]
[TestCase(@"c:\Test\\\\", @"C:\Test\\")]
[TestCase(@"c:\Test", @"C:\Test\\")]
public void paths_should_be_equeal(string first, string second)
{
DiskProvider.PathEquals(first, second).Should().BeTrue();
}
[TestCase(@"D:\Test", @"C:\Test\")]
[TestCase(@"D:\Test\Test", @"C:\TestTest\")]
public void paths_should_not_be_equeal(string first, string second)
{
DiskProvider.PathEquals(first, second).Should().BeFalse();
}
private void VerifyCopy()
{
BinFolder.Refresh();

View File

@ -175,5 +175,11 @@ public virtual string ReadAllText(string filePath)
{
return File.ReadAllText(filePath);
}
public static bool PathEquals(string firstPath, string secondPath)
{
return String.Equals(firstPath.NormalizePath(), secondPath.NormalizePath(), StringComparison.InvariantCultureIgnoreCase);
}
}
}

View File

@ -102,7 +102,7 @@ public virtual void StopServer()
foreach (var process in _processProvider.GetProcessByName("IISExpress"))
{
Logger.Info("[{0}]IIS Process found. Path:{1}", process.Id, process.StartPath);
if (process.StartPath.NormalizePath() == _enviromentProvider.GetIISExe().NormalizePath())
if (DiskProvider.PathEquals(process.StartPath, _enviromentProvider.GetIISExe()))
{
Logger.Info("[{0}]Process is considered orphaned.", process.Id);
_processProvider.Kill(process.Id);

View File

@ -218,7 +218,7 @@ public void nzbsorg_search_returns_valid_results(string title, int season, int e
[TestCase("simpsons", 21, 23)]
[TestCase("Hawaii Five-0 (2010)", 1, 1)]
[TestCase("In plain Sight", 1, 11)]
[TestCase("In plain Sight", 1, 11, Ignore = true)]
public void newzbin_search_returns_valid_results(string title, int season, int episode)
{
var mocker = new AutoMoqer();

View File

@ -91,7 +91,7 @@ private void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
{
var target = GetTaggedFolderName(directory, status);
if (!String.Equals(target.NormalizePath(), directory.FullName.NormalizePath(), StringComparison.InvariantCultureIgnoreCase))
if (!DiskProvider.PathEquals(target, directory.FullName))
{
Logger.Warn("Unable to download [{0}]. Status: {1}",directory.Name, status);
_diskProvider.MoveDirectory(directory.FullName, target);

View File

@ -72,11 +72,9 @@ public List<String> GetUnmappedFolders(string path)
foreach (string seriesFolder in _diskProvider.GetDirectories(path))
{
var cleanPath = new DirectoryInfo(seriesFolder).FullName.NormalizePath();
if (!_seriesProvider.SeriesPathExists(cleanPath))
if (!_seriesProvider.SeriesPathExists(seriesFolder))
{
results.Add(cleanPath);
results.Add(seriesFolder.Normalize());
}
}

View File

@ -179,9 +179,7 @@ public virtual void DeleteSeries(int seriesId)
public virtual bool SeriesPathExists(string path)
{
var normilizedPath = path.NormalizePath();
return GetAllSeries().Any(s => s.Path.NormalizePath() == normilizedPath);
return GetAllSeries().Any(s => DiskProvider.PathEquals(s.Path, path));
}
public virtual List<Series> SearchForSeries(string title)