google / google/jimfs

setPermissions and setTimes on symlinks don't behave as on Unix/macOS

Open
#119 0 comments 0 reactions 1 assignee Claimed by @cgdecker View on GitHub
P3 type=defect
Dominant language
Java
Stars
2.6k
Forks
296
Avg merge
9m
Merged PRs (30d)
7

Description

The following:

```java
BasicFileAttributeView attributes = Files.getFileAttributeView(symlink, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
if (attributes != null) {
attributes.setTimes(fileTime, null, null);
}
```

only works in openjdk since JDK11 https://bugs.openjdk.java.net/browse/JDK-8220793, so it may be worth adding a special behavior to fail when running on earlier versions.

```java
PosixFileAttributeView attributes = Files.getFileAttributeView(symlink, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
if (attributes != null) {
attributes.setPermissions(modes);
}
```

should fail when the link is dangling (as it should only operates on the target of the link on Unix - it's possible on macOS, but there is no such support in `java.nio`)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.