mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Fixed: Mono internals does not properly copy/move symlinks, but instead copies the contents.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Mono.Unix;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Test.DiskTests;
|
||||
@@ -35,5 +37,55 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
|
||||
entry.FileAccessPermissions &= ~(FileAccessPermissions.UserWrite | FileAccessPermissions.GroupWrite | FileAccessPermissions.OtherWrite);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_move_symlink()
|
||||
{
|
||||
var tempFolder = GetTempFilePath();
|
||||
Directory.CreateDirectory(tempFolder);
|
||||
|
||||
var file = Path.Combine(tempFolder, "target.txt");
|
||||
var source = Path.Combine(tempFolder, "symlink_source.txt");
|
||||
var destination = Path.Combine(tempFolder, "symlink_destination.txt");
|
||||
|
||||
File.WriteAllText(file, "Some content");
|
||||
|
||||
new UnixSymbolicLinkInfo(source).CreateSymbolicLinkTo(file);
|
||||
|
||||
Subject.MoveFile(source, destination);
|
||||
|
||||
File.Exists(file).Should().BeTrue();
|
||||
File.Exists(source).Should().BeFalse();
|
||||
File.Exists(destination).Should().BeTrue();
|
||||
UnixFileSystemInfo.GetFileSystemEntry(destination).IsSymbolicLink.Should().BeTrue();
|
||||
|
||||
File.ReadAllText(destination).Should().Be("Some content");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_copy_symlink()
|
||||
{
|
||||
var tempFolder = GetTempFilePath();
|
||||
Directory.CreateDirectory(tempFolder);
|
||||
|
||||
var file = Path.Combine(tempFolder, "target.txt");
|
||||
var source = Path.Combine(tempFolder, "symlink_source.txt");
|
||||
var destination = Path.Combine(tempFolder, "symlink_destination.txt");
|
||||
|
||||
File.WriteAllText(file, "Some content");
|
||||
|
||||
new UnixSymbolicLinkInfo(source).CreateSymbolicLinkTo(file);
|
||||
|
||||
Subject.CopyFile(source, destination);
|
||||
|
||||
File.Exists(file).Should().BeTrue();
|
||||
File.Exists(source).Should().BeTrue();
|
||||
File.Exists(destination).Should().BeTrue();
|
||||
UnixFileSystemInfo.GetFileSystemEntry(source).IsSymbolicLink.Should().BeTrue();
|
||||
UnixFileSystemInfo.GetFileSystemEntry(destination).IsSymbolicLink.Should().BeTrue();
|
||||
|
||||
File.ReadAllText(source).Should().Be("Some content");
|
||||
File.ReadAllText(destination).Should().Be("Some content");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user