This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 3ca55e9 PathUtils.setReadOnly(Path, boolean, LinkOption...) should
add READ_* file attributes when using POSIX.
3ca55e9 is described below
commit 3ca55e92e8493429317554ff220e71bf0125cf7f
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Sep 26 13:42:28 2021 -0400
PathUtils.setReadOnly(Path, boolean, LinkOption...) should add READ_*
file attributes when using POSIX.
---
src/changes/changes.xml | 3 +++
src/main/java/org/apache/commons/io/file/PathUtils.java | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f08fdc6..107874b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -101,6 +101,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IO-638" dev="ggregory" type="fix" due-to="Thayne McCombs,
Gary Gregory">
Infinite loop in CharSequenceInputStream.read for 4-byte characters
with UTF-8 and 3-byte buffer.
</action>
+ <action issue="IO-638" dev="ggregory" type="fix" due-to="Gary Gregory">
+ PathUtils.setReadOnly(Path, boolean, LinkOption...) should add READ_*
file attributes when using POSIX.
+ </action>
<!-- ADD -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add BrokenReader.INSTANCE.
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java
b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 9d65243..f9968c2 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -1169,6 +1169,9 @@ public final class PathUtils {
// java.lang.IllegalArgumentException: 'unix:readonly' not
recognized
final PosixFileAttributes readAttributes =
posixFileAttributeView.readAttributes();
final Set<PosixFilePermission> permissions =
readAttributes.permissions();
+ permissions.add(PosixFilePermission.OWNER_READ);
+ permissions.add(PosixFilePermission.GROUP_READ);
+ permissions.add(PosixFilePermission.OTHERS_READ);
permissions.remove(PosixFilePermission.OWNER_WRITE);
permissions.remove(PosixFilePermission.GROUP_WRITE);
permissions.remove(PosixFilePermission.OTHERS_WRITE);