-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made FileUtil to copy POSIX permissions #4654
Conversation
Two questions:
|
Well that API is ancient, from those times, when the Executable permissions could not be set by Java (pre-Java 6) without some magic. As a DevOps Engineer, I'm working with a lot of scripts recently, so I thought I fix my issue when copy them in the IDE. That's all. I do not know how important Windows ACL for other people, well if that's really missed, contributions are welcome! |
3b49c26
to
218e6c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me - left a comment but feel free to ignore it.
copy(bufIn, bufOut); | ||
copyPosixPerms(source, dest); | ||
copyAttributes(source, dest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought:
Files.copy(...) would copy posix permissions too (there is also a COPY_ATTRIBUTES option). Alternative impl would check if its an actual file first, if it is, it would use Files.copy() with paths, otherwise use streams.
Maybe its worth thinking about refreshing this code if it isn't too much work? Otherwise we end up reimplementing everything what Files.copy already does.
platform/openide.filesystems/test/unit/src/org/openide/filesystems/FileUtilTest.java
Outdated
Show resolved
Hide resolved
<author login="lkishalmi"/> | ||
<compatibility addition="yes" semantic="compatible"/> | ||
<description> | ||
<a href="@TOP@/org/openide/filesystems/FileUtil.html#">FileUtil.copy</a> now preserves POSIX permissions if possible during file copy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing anchor to the FileUtil.copy chapter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always dreamed about 1:1 mapping between Path and FileObject. They could delegate to each other. Always. E.g. the new methods shall never return null.
@lkishalmi still a few things to address here. I also agree with @mbien and @jtulach about 1:1 mapping behaviour with Path and Files::copy COPY_ATTRIBUTES. Not sure whether at least minimal things can be addressed and merged for NB16 or we should push all changes to NB17? |
I hope I can make those minimal changes needed. The day is just started for me. If I can't make that happen, you are right, I'll move this to NB17. |
@lkishalmi any thoughts on progressing this one? It's getting close to missing the NB17 cut too. |
Well, this PR won't make that dream true. Probably one day when someone would have a lot of time. AFAIK we need to provide a few FileSystem implementation to be able to use As of returning |
218e6c6
to
ba03950
Compare
Unfortunately |
BTW. This PR marks all checks passed as it was missing the |
ba03950
to
8a88662
Compare
<change id="fileutil.niofilepath"> | ||
<api name="filesystems"/> | ||
<summary>FileUtil can convert FileObject to/from java.nio.file.Path.</summary> | ||
<version major="9" minor="30"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9.32 (master has currently 9.31). We should probably bump version for each api change to allow proper autoupdates from the daily builds for those bleeding-edge testers.
* This is the inverse operation of {@link #toFileObject}. | ||
* @param fo FileObject whose corresponding Path will be looked for | ||
* @return java.nio.file.Path or null if no corresponding File exists. | ||
* @since 9.30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9.31 if apichanges is corrected.
@@ -567,6 +569,7 @@ static FileObject copyFileImpl(FileObject source, FileObject destFolder, String | |||
} | |||
|
|||
copy(bufIn, bufOut); | |||
copyPosixPerms(source, dest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make a mote in method's Javadoc about behaviour enhancement since 9.31(2), people can stop writing attribute preserving code, if they read javadoc :)
8a88662
to
47676c2
Compare
Well as a DevOps engineer, I copy scripts and other executable inside the IDE. They lose the executable flag. That bothers me for years. Here is how I try to fix that.
Also added
FileObject
Path
conversion methods, to make the life easier.