8000 Preserve original file information for tar · lgrignon/typescript.java@f89fc2c · GitHub
[go: up one dir, main page]

Skip to content

Commit f89fc2c

Browse files
authored
Preserve original file information for tar
Looking for "bin" folder seems a bit "tricky" to me... For tar files we should keep original executable permissions as this info is available. For zip files executable information could be available for UNIX systems but in current ZipEntry implementation that info seems to be not available.
1 parent 95f09ee commit f89fc2c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/ts.core/src/ts/utils/ZipUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public static void extractZip(File file, File destination) throws IOException {
102102

103103
// Close the stream
104104
out.close();
105+
// Preserve original modification date
106+
extracted.setLastModified(entry.getTime());
105107
if (extracted.getParent().contains(BIN_FOLDER)) {
106108
extracted.setExecutable(true);
107109
}
@@ -166,9 +168,13 @@ public static void extractTar(File file, File destination) throws IOException {
166168

167169
// Close the stream
168170
out.close();
169-
if (extractedFile.getParent().contains(BIN_FOLDER)) {
170-
extractedFile.setExecutable(true);
171-
}
171+
// Preserve original modification date
172+
extractedFile.setLastModified(entry.getTime());
173+
long mode = entry.getMode();
174+
if ((mode & 00100) > 0) {
175+
// Preserve execute permissions
176+
extractedFile.setExecutable(true, (mode & 00001) == 0);
177+
}
172178
break;
173179
case TarEntry.LINK:
174180
File linkFile = new File(destination, outFilename);

0 commit comments

Comments
 (0)
0