diff --git a/src/Zio.Tests/FileSystems/TestMemoryFileSystem.cs b/src/Zio.Tests/FileSystems/TestMemoryFileSystem.cs index e1bb9c6..26a60bd 100644 --- a/src/Zio.Tests/FileSystems/TestMemoryFileSystem.cs +++ b/src/Zio.Tests/FileSystems/TestMemoryFileSystem.cs @@ -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 diff --git a/src/Zio/FileSystems/ComposeFileSystem.cs b/src/Zio/FileSystems/ComposeFileSystem.cs index 1dc14b4..7605c7d 100644 --- a/src/Zio/FileSystems/ComposeFileSystem.cs +++ b/src/Zio/FileSystems/ComposeFileSystem.cs @@ -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); } \ No newline at end of file diff --git a/src/Zio/FileSystems/MountFileSystem.cs b/src/Zio/FileSystems/MountFileSystem.cs index 4b486af..514b17f 100644 --- a/src/Zio/FileSystems/MountFileSystem.cs +++ b/src/Zio/FileSystems/MountFileSystem.cs @@ -593,6 +593,19 @@ protected override bool TryResolveLinkTargetImpl(UPath linkPath, out UPath resol return true; } + /// + 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); + } + /// protected override IEnumerable EnumeratePathsImpl(UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget) {