25
25
import org .apache .commons .compress .archivers .zip .DefaultBackingStoreSupplier ;
26
26
import org .apache .commons .compress .archivers .zip .ParallelScatterZipCreator ;
27
27
import org .apache .commons .compress .archivers .zip .ScatterZipOutputStream ;
28
+ import org .apache .commons .compress .archivers .zip .UnixStat ;
28
29
import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
29
30
import org .apache .commons .compress .archivers .zip .ZipArchiveEntryRequest ;
30
31
import org .apache .commons .compress .archivers .zip .ZipArchiveOutputStream ;
@@ -44,6 +45,9 @@ public class ParallelCommonsCompressArchiveCreator implements ArchiveCreator {
44
45
45
46
private static final InputStreamSupplier EMPTY_SUPPLIER = () -> new ByteArrayInputStream (new byte [0 ]);
46
47
48
+ private static final int DIR_UNIX_MODE = UnixStat .DIR_FLAG | UnixStat .DEFAULT_DIR_PERM ;
49
+ private static final int FILE_UNIX_MODE = UnixStat .FILE_FLAG | UnixStat .DEFAULT_FILE_PERM ;
50
+
47
51
private final Path archivePath ;
48
52
private final FileTime entryTimestamp ;
49
53
private final ZipArchiveOutputStream archive ;
@@ -84,6 +88,7 @@ public class ParallelCommonsCompressArchiveCreator implements ArchiveCreator {
84
88
public void addManifest (Manifest manifest ) throws IOException {
85
89
// we add the manifest directly to the final archive to make sure it is the first element added
86
90
ZipArchiveEntry metaInfArchiveEntry = new ZipArchiveEntry ("META-INF/" );
91
+ metaInfArchiveEntry .setUnixMode (DIR_UNIX_MODE );
87
92
normalizeTimestamps (metaInfArchiveEntry );
88
93
archive .putArchiveEntry (metaInfArchiveEntry );
89
94
archive .closeArchiveEntry ();
@@ -93,6 +98,7 @@ public void addManifest(Manifest manifest) throws IOException {
93
98
byte [] manifestBytes = baos .toByteArray ();
94
99
95
100
ZipArchiveEntry manifestEntry = new ZipArchiveEntry ("META-INF/MANIFEST.MF" );
101
+ manifestEntry .setUnixMode (FILE_UNIX_MODE );
96
102
normalizeTimestamps (manifestEntry );
97
103
manifestEntry .setSize (manifestBytes .length );
98
104
archive .putArchiveEntry (manifestEntry );
@@ -169,15 +175,18 @@ private void addDirectoryEntry(final ZipArchiveEntry zipArchiveEntry) throws IOE
169
175
}
170
176
normalizeTimestamps (zipArchiveEntry );
171
177
zipArchiveEntry .setMethod (compressionMethod );
178
+ zipArchiveEntry .setUnixMode (DIR_UNIX_MODE );
172
179
directories .addArchiveEntry (ZipArchiveEntryRequest .createZipArchiveEntryRequest (zipArchiveEntry , EMPTY_SUPPLIER ));
173
180
}
174
181
175
182
private void addEntry (final ZipArchiveEntry zipArchiveEntry , final InputStreamSupplier streamSupplier ) throws IOException {
176
183
normalizeTimestamps (zipArchiveEntry );
177
184
zipArchiveEntry .setMethod (compressionMethod );
178
185
if (zipArchiveEntry .isDirectory () && !zipArchiveEntry .isUnixSymlink ()) {
186
+ zipArchiveEntry .setUnixMode (DIR_UNIX_MODE );
179
187
directories .addArchiveEntry (ZipArchiveEntryRequest .createZipArchiveEntryRequest (zipArchiveEntry , streamSupplier ));
180
188
} else {
189
+ zipArchiveEntry .setUnixMode (FILE_UNIX_MODE );
181
190
scatterZipCreator .addArchiveEntry (zipArchiveEntry , streamSupplier );
182
191
}
183
192
}
0 commit comments