Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/ts.core/src/ts/utils/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public static void extractZip(File file, File destination) throws IOException {

// Close the stream
out.close();
// Preserve original modification date
extracted.setLastModified(entry.getTime());
if (extracted.getParent().contains(BIN_FOLDER)) {
extracted.setExecutable(true);
}
Expand Down Expand Up @@ -166,9 +168,13 @@ public static void extractTar(File file, File destination) throws IOException {

// Close the stream
out.close();
if (extractedFile.getParent().contains(BIN_FOLDER)) {
extractedFile.setExecutable(true);
}
// Preserve original modification date
extractedFile.setLastModified(entry.getTime());
long mode = entry.getMode();
if ((mode & 00100) > 0) {
// Preserve execute permissions
extractedFile.setExecutable(true, (mode & 00001) == 0);
}
break;
case TarEntry.LINK:
File linkFile = new File(destination, outFilename);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done too for link, no?

Copy link
Contributor Author

@rubensa rubensa Jul 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure.
For hard links It seems that is not necessary as It should keep original (linked) file permissions.
As for symbolic links, by default, It also seems that is not necessary (I checked with node-v6.9.4-linux-x64.tar.gz and npm symlink has all permissions -777-...). Surely we could/sould do something like:
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-xr--"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); Files.createSymbolicLink(symLinkFile.toPath(), symTarget, attr);
but before that, we should check that current system is POSIX and "gess" permission pattern (in the example "rwxr-xr--") from entry attributes. (I'm not sure but I think that if system is not POSIX and you try to pass those attrs an Exception is thrown).

Have you thought on using Apache Commons Compress to avoid this low level implementation?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for your feedback. If it works for you, it's OK.

Have you thought on using Apache Commons Compress to avoid this low level implementation?

I would like to avoid having dependencies just to extract node.js. We will see in the future if we have so many problem, perhaps I will switch to appache commons compress.

Expand Down