RFR 8229888: Zip FS does not retain permissions when updating a Zip file
Alan Bateman
Alan.Bateman at oracle.com
Tue Dec 3 21:04:02 UTC 2019
On 03/12/2019 00:59, Lance Andersen wrote:
> HI all,
>
> Please review the proposed fix for an issue with Zip FS where the
> permissions set on the Zip file are not retained when the Zip file is
> updated.
>
> The webrev can be found at:
> http://cr.openjdk.java.net/~lancea/8229888/webrev.00/index.html
>
Testing the underlying FileStore to see if supports "posix" may be
problematic or costly here as it requires finding the mount entry file
the underlying file store. You should find that it is much more
efficient to just call getPosixFileAttributes and catch UOE (using
exceptions for control flow is not nice of course but you will avoid a
lot of issues). In passing, I should mention that the non-stringy way to
to check if POSIX file permissions are support is to invoke on
supportsFileAttributeView(PosixFIleAttributeView.class).
One other approach to look at is just letting Files.move copy the file
attributes. It will copy file permissions and attempt to copy all other
attributes (it only fails if it can't copy the basic file attributes to
the file in its new location). Another point is that the
Files.newOutputStream to create the file next to the original zip file
can be created with initial file attributes. Combined with Files.move it
means there is another way to do this. I only mention is because I
assume there will be follow on issues to fix up other file attributes of
the zip file that are lost when it is re-created.
-Alan
More information about the nio-dev
mailing list