Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Ramstack.FileSystem.Abstractions/VirtualFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public ValueTask CopyToAsync(string destinationPath, bool overwrite, Cancellatio
/// </remarks>
public ValueTask CopyToAsync(VirtualFile destination, bool overwrite, CancellationToken cancellationToken = default)
{
EnsureWritable();
destination.EnsureWritable();
destination.Refresh();

if (destination.FileSystem != FileSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Ramstack.FileSystem.Abstractions\Ramstack.FileSystem.Abstractions.csproj" />
<ProjectReference Include="..\..\src\Ramstack.FileSystem.Physical\Ramstack.FileSystem.Physical.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Security.Cryptography;
using System.Text;

using Ramstack.FileSystem.Physical;

namespace Ramstack.FileSystem.Specification.Tests;

/// <summary>
Expand Down Expand Up @@ -353,6 +355,38 @@ await Assert.ThatAsync(
Throws.Exception);
}

[Test]
public async Task File_Readonly_ReadonlyToWritable_Succeeds()
{
using var fs = GetFileSystem();
using var ds = new PhysicalFileSystem(
Path.Combine(
Path.GetTempPath(),
Path.GetRandomFileName()));

if (!fs.IsReadOnly)
return;

var src = fs.GetFile("/project/README.md");
var dst = ds.GetFile("/README.md");

await src.CopyToAsync(dst);

Assert.That(
await dst.ExistsAsync(),
Is.True);

Assert.That(
await ds.FileExistsAsync("/README.md"),
Is.True);

Assert.That(
await src.ReadAllTextAsync(),
Is.EqualTo(await src.ReadAllTextAsync()));

Directory.Delete(ds.Root, true);
}

[Test]
public async Task File_CopyTo_Path()
{
Expand Down
Loading