Skip to content

Commit

Permalink
Fix JoinedFileSystem returning views that some source filesystems did…
Browse files Browse the repository at this point in the history
…n't support.
  • Loading branch information
AlexIIL committed Dec 7, 2024
1 parent 53dd4ab commit 7a2754a
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -435,15 +436,25 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> 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
Expand Down

0 comments on commit 7a2754a

Please sign in to comment.