1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2025-01-02 21:24:56 +00:00

Fixed: Changing series to another root folder without moving files

This commit is contained in:
Bogdan 2024-10-25 09:42:55 +03:00 committed by Mark McDowall
parent ff724b7f40
commit 240a0339be
2 changed files with 21 additions and 1 deletions

View file

@ -414,5 +414,25 @@ namespace NzbDrone.Common.Test
{ {
path.GetCleanPath().Should().Be(cleanPath); path.GetCleanPath().Should().Be(cleanPath);
} }
[TestCase(@"C:\Test\", @"C:\Test\Series Title", "Series Title")]
[TestCase(@"C:\Test\", @"C:\Test\Collection\Series Title", @"Collection\Series Title")]
[TestCase(@"C:\Test\mydir\", @"C:\Test\mydir\Collection\Series Title", @"Collection\Series Title")]
[TestCase(@"\\server\share", @"\\server\share\Series Title", "Series Title")]
[TestCase(@"\\server\share\mydir\", @"\\server\share\mydir\/Collection\Series Title", @"Collection\Series Title")]
public void windows_path_should_return_relative_path(string parentPath, string childPath, string relativePath)
{
parentPath.GetRelativePath(childPath).Should().Be(relativePath);
}
[TestCase(@"/test", "/test/Series Title", "Series Title")]
[TestCase(@"/test/", "/test/Collection/Series Title", "Collection/Series Title")]
[TestCase(@"/test/mydir", "/test/mydir/Series Title", "Series Title")]
[TestCase(@"/test/mydir/", "/test/mydir/Collection/Series Title", "Collection/Series Title")]
[TestCase(@"/test/mydir/", @"/test/mydir/\Collection/Series Title", "Collection/Series Title")]
public void unix_path_should_return_relative_path(string parentPath, string childPath, string relativePath)
{
parentPath.GetRelativePath(childPath).Should().Be(relativePath);
}
} }
} }

View file

@ -85,7 +85,7 @@ namespace NzbDrone.Common.Extensions
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath); throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
} }
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar); return childPath.Substring(parentPath.Length).Trim('\\', '/');
} }
public static string GetParentPath(this string childPath) public static string GetParentPath(this string childPath)