From 7a2754afa4d32bf235d2af49b0776cbb131f4520 Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Sat, 7 Dec 2024 17:38:27 +0000 Subject: [PATCH] Fix JoinedFileSystem returning views that some source filesystems didn't support. --- .../QuiltJoinedFileSystemProvider.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/quiltmc/loader/impl/filesystem/QuiltJoinedFileSystemProvider.java b/src/main/java/org/quiltmc/loader/impl/filesystem/QuiltJoinedFileSystemProvider.java index 7d335d2e6..e376498b8 100644 --- a/src/main/java/org/quiltmc/loader/impl/filesystem/QuiltJoinedFileSystemProvider.java +++ b/src/main/java/org/quiltmc/loader/impl/filesystem/QuiltJoinedFileSystemProvider.java @@ -37,6 +37,7 @@ import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.StandardOpenOption; +import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.FileAttributeView; @@ -435,15 +436,25 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException { @Override public V getFileAttributeView(Path path, Class type, LinkOption... options) { + V firstView = null; + V firstExistingView = null; + QuiltJoinedPath quiltPath = toAbsQuiltPath(path); for (int i = 0; i < quiltPath.fs.getBackingPathCount(); i++) { Path real = quiltPath.fs.getBackingPath(i, quiltPath); V view = Files.getFileAttributeView(real, type, options); - if (view != null) { - return view; + if (view == null) { + // Only return view types that are supported by all providers + return null; + } + if (firstExistingView == null && FasterFiles.exists(real, options)) { + firstExistingView = view; + } + if (firstView == null) { + firstView = view; } } - return null; + return firstExistingView != null ? firstExistingView : firstView; } @Override