-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[JENKINS-57855] read-only flag of folders on windows #4059
Conversation
On windows the current way of removing the read only flag is not working for folders. Using the Files api this can be solved.
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 overall. Maybe SecurityException
s need to be handled in the code
if (dos != null) | ||
{ | ||
dos.setReadOnly(false); | ||
} |
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.
Should it handle the SecurityException and wrap it into IOException? https://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/DosFileAttributeView.html#setReadOnly(boolean)
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.
Then we would need to wrap almost all File stuff in this class.
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.
fair point
* If on Windows a folder has a read only attribute set, the file.setWritable(true) doesn't work (JENKINS-57855) | ||
*/ | ||
DosFileAttributeView dos = Files.getFileAttributeView(path, DosFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); | ||
if (dos != null) |
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.
Is it supposed to fall through and call path.toFile().setWritable(true);
in such case? Looks so
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 would assume that it is not necessary to call the setWritable(true) for windows.
If this fails then the setWritable would also fail I guess.
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 think it is fine and ready to go. Thanks @mawinter69 !
Just to avoid future regressions, an Windows-only unit test could be created (Assume
class allows to create optional tests in JUnit)
I am going to merge it towards the next weekly if no negative feedback |
See JENKINS-57855.
Proposed changelog entries
Submitter checklist
* Use the
Internal:
prefix if the change has no user-visible impact (API, test frameworks, etc.)Desired reviewers