fixup! Fixed: Updating series path from different OS paths
This commit is contained in:
parent
ff12c36204
commit
1e51854cb5
|
@ -135,9 +135,14 @@ namespace NzbDrone.Common.Test
|
||||||
[TestCase(@"C:\test", @"C:\Test\mydir\")]
|
[TestCase(@"C:\test", @"C:\Test\mydir\")]
|
||||||
public void windows_path_should_be_parent(string parentPath, string childPath)
|
public void windows_path_should_be_parent(string parentPath, string childPath)
|
||||||
{
|
{
|
||||||
var expectedResult = OsInfo.IsWindows;
|
parentPath.IsParentPath(childPath).Should().Be(true);
|
||||||
|
}
|
||||||
|
|
||||||
parentPath.IsParentPath(childPath).Should().Be(expectedResult);
|
[TestCase("/test", "/test/mydir/")]
|
||||||
|
[TestCase("/test/", "/test/mydir")]
|
||||||
|
public void posix_path_should_be_parent(string parentPath, string childPath)
|
||||||
|
{
|
||||||
|
parentPath.IsParentPath(childPath).Should().Be(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(@"C:\Test\mydir", @"C:\Test")]
|
[TestCase(@"C:\Test\mydir", @"C:\Test")]
|
||||||
|
|
|
@ -360,6 +360,11 @@ namespace NzbDrone.Common.Disk
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(OsPath other)
|
public bool Equals(OsPath other)
|
||||||
|
{
|
||||||
|
return Equals(other, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(OsPath other, bool ignoreTrailingSlash)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(other, null))
|
if (ReferenceEquals(other, null))
|
||||||
{
|
{
|
||||||
|
@ -371,8 +376,8 @@ namespace NzbDrone.Common.Disk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var left = PathWithoutTrailingSlash;
|
var left = ignoreTrailingSlash ? PathWithoutTrailingSlash : _path;
|
||||||
var right = other.PathWithoutTrailingSlash;
|
var right = ignoreTrailingSlash ? other.PathWithoutTrailingSlash : other._path;
|
||||||
|
|
||||||
if (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows)
|
if (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows)
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,14 +92,7 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
public static string GetParentPath(this string childPath)
|
public static string GetParentPath(this string childPath)
|
||||||
{
|
{
|
||||||
var cleanPath = childPath.GetCleanPath();
|
var path = new OsPath(childPath).Directory;
|
||||||
|
|
||||||
if (cleanPath.IsNullOrWhiteSpace())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var path = new OsPath(cleanPath).Directory;
|
|
||||||
|
|
||||||
return path == OsPath.Null ? null : path.PathWithoutTrailingSlash;
|
return path == OsPath.Null ? null : path.PathWithoutTrailingSlash;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +127,7 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
while (child.Directory != OsPath.Null)
|
while (child.Directory != OsPath.Null)
|
||||||
{
|
{
|
||||||
if (child.Directory.Equals(parent))
|
if (child.Directory.Equals(parent, true))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue