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
17 changes: 17 additions & 0 deletions src/Zio.Tests/FileSystems/TestMemoryFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ public void TestMoveFileCross()
Assert.Equal(TriggerMemoryFileSystem.TriggerType.Move, fs.Triggered);
}

[Fact]
public void TestMoveFileCrossMount()
{
var fs = new TriggerMemoryFileSystem();
fs.CreateDirectory("/sub1");
fs.CreateDirectory("/sub2");
var mount = new MountFileSystem();
var sub1 = new SubFileSystem(fs, "/sub1");
var sub2 = new SubFileSystem(fs, "/sub2");
mount.Mount("/sub2-mount", sub2);
sub1.WriteAllText("/file.txt", "test");
sub1.MoveFileCross("/file.txt", mount, "/sub2-mount/file.txt");
Assert.Equal("test", sub2.ReadAllText("/file.txt"));
Assert.False(sub1.FileExists("/file.txt"));
Assert.Equal(TriggerMemoryFileSystem.TriggerType.Move, fs.Triggered);
}

private sealed class TriggerMemoryFileSystem : MemoryFileSystem
{
public enum TriggerType
Expand Down
2 changes: 1 addition & 1 deletion src/Zio/FileSystems/ComposeFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,5 @@ protected override UPath ConvertPathFromInternalImpl(string innerPath)
protected abstract UPath ConvertPathFromDelegate(UPath path);

protected override (IFileSystem FileSystem, UPath Path) ResolvePathImpl(UPath path)
=> FallbackSafe.ResolvePath(ConvertPathToDelegate(path));
=> Fallback?.ResolvePath(ConvertPathToDelegate(path)) ?? base.ResolvePathImpl(path);
}
13 changes: 13 additions & 0 deletions src/Zio/FileSystems/MountFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,19 @@ protected override bool TryResolveLinkTargetImpl(UPath linkPath, out UPath resol
return true;
}

/// <inheritdoc />
protected override (IFileSystem FileSystem, UPath Path) ResolvePathImpl(UPath path)
{
var mountfs = TryGetMountOrNext(ref path);

if (mountfs is null)
{
return base.ResolvePathImpl(path);
}

return mountfs.ResolvePath(path);
}

/// <inheritdoc />
protected override IEnumerable<UPath> EnumeratePathsImpl(UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget)
{
Expand Down