Details
Description
A DESCRIPTION OF THE PROBLEM :
I don't think there is a better way to describe the problem better than the code itself.
Let's assume we have "comment.zip" with permissions "-rw-rw-r--" on Desktop, the code will change the permissions to "-rw-------"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Zip file permissions shouldn't change.
ACTUAL -
Zip file permissions change to "-rw-------"
---------- BEGIN SOURCE ----------
String zipPath = "/home/ahashem/Desktop/comment.zip";
URI uri = URI.create("jar:file:" + zipPath);
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
Path pathInZipFile = fs.getPath("comment.txt");
Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
String zipPath = "/home/ahashem/Desktop/comment.zip";
URI uri = URI.create("jar:file:" + zipPath);
Set<PosixFilePermission> defaultPermissions = Files.getPosixFilePermissions(Paths.get(zipPath));
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
Path pathInZipFile = fs.getPath("comment.txt");
Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
}
Files.setPosixFilePermissions(Paths.get(zipPath), defaultPermissions);
FREQUENCY : always
I don't think there is a better way to describe the problem better than the code itself.
Let's assume we have "comment.zip" with permissions "-rw-rw-r--" on Desktop, the code will change the permissions to "-rw-------"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Zip file permissions shouldn't change.
ACTUAL -
Zip file permissions change to "-rw-------"
---------- BEGIN SOURCE ----------
String zipPath = "/home/ahashem/Desktop/comment.zip";
URI uri = URI.create("jar:file:" + zipPath);
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
Path pathInZipFile = fs.getPath("comment.txt");
Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
String zipPath = "/home/ahashem/Desktop/comment.zip";
URI uri = URI.create("jar:file:" + zipPath);
Set<PosixFilePermission> defaultPermissions = Files.getPosixFilePermissions(Paths.get(zipPath));
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
Path pathInZipFile = fs.getPath("comment.txt");
Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
}
Files.setPosixFilePermissions(Paths.get(zipPath), defaultPermissions);
FREQUENCY : always
Attachments
Issue Links
- duplicates
-
JDK-8229888 (zipfs) Updating an existing zip file does not preserve original permissions
- Resolved