mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-17 10:45:49 +02:00
Fixed: Not properly getting the parent of a folder with a trailing slash
GetParentFolder will trim trailing slashes
This commit is contained in:
parent
1b3993bf6a
commit
3ed8f0ea84
@ -346,6 +346,15 @@ public void check_last_write()
|
|||||||
Console.WriteLine(GetFilledTempFolder().LastWriteTimeUtc);
|
Console.WriteLine(GetFilledTempFolder().LastWriteTimeUtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetParentFolder_should_remove_trailing_slash_before_getting_parent_folder()
|
||||||
|
{
|
||||||
|
var path = @"C:\Test\TV\".AsOsAgnostic();
|
||||||
|
var parent = @"C:\Test".AsOsAgnostic();
|
||||||
|
|
||||||
|
Subject.GetParentFolder(path).Should().Be(parent);
|
||||||
|
}
|
||||||
|
|
||||||
private void VerifyCopy(string source, string destination)
|
private void VerifyCopy(string source, string destination)
|
||||||
{
|
{
|
||||||
var sourceFiles = Directory.GetFileSystemEntries(source, "*", SearchOption.AllDirectories).Select(v => v.Substring(source.Length + 1)).ToArray();
|
var sourceFiles = Directory.GetFileSystemEntries(source, "*", SearchOption.AllDirectories).Select(v => v.Substring(source.Length + 1)).ToArray();
|
||||||
|
@ -355,7 +355,7 @@ public string GetParentFolder(string path)
|
|||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath();
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
|
|
||||||
var parent = Directory.GetParent(path);
|
var parent = Directory.GetParent(path.TrimEnd(Path.DirectorySeparatorChar));
|
||||||
|
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user