Fixed some issue around path normalization.

pull/4/head
kay.one 13 years ago
parent e269494ff8
commit bfe4de7a08

@ -94,6 +94,26 @@ namespace NzbDrone.Common.Test
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();

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

@ -102,7 +102,7 @@ namespace NzbDrone.Common
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);

@ -218,7 +218,7 @@ namespace NzbDrone.Core.Test
[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();

@ -91,7 +91,7 @@ namespace NzbDrone.Core.Providers
{
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);

@ -72,11 +72,9 @@ namespace NzbDrone.Core.Providers
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());
}
}

@ -179,9 +179,7 @@ namespace NzbDrone.Core.Providers
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)

Loading…
Cancel
Save