Skip to content

Commit 7115400

Browse files
committed
Preserve zipped directory permissions
for adding to existing zips
1 parent 68ef769 commit 7115400

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

os/src/ZipOps.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,22 @@ object zip {
7979
excludePatterns,
8080
includePatterns,
8181
(path, sub) => {
82-
os.copy(path, opened / sub, createFolders = true)
82+
val dest = opened / sub
83+
84+
if (os.isDir(path))
85+
os.makeDir.all(dest)
86+
else
87+
os.copy(path, dest, createFolders = true)
88+
8389
if (!isWin && Runtime.version.feature >= 14)
84-
Files.setPosixFilePermissions((opened / sub).wrapped, os.perms(path).toSet())
90+
Files.setPosixFilePermissions(dest.wrapped, os.perms(path).toSet())
91+
8592
if (!preserveMtimes) {
86-
os.mtime.set(opened / sub, 0)
93+
os.mtime.set(dest, 0)
8794
// This is the only way we can properly zero out filesystem metadata within the
8895
// Zip file filesystem; `os.mtime.set` is not enough
8996
val view =
90-
Files.getFileAttributeView((opened / sub).wrapped, classOf[BasicFileAttributeView])
97+
Files.getFileAttributeView(dest.wrapped, classOf[BasicFileAttributeView])
9198
view.setTimes(FileTime.fromMillis(0), FileTime.fromMillis(0), FileTime.fromMillis(0))
9299
}
93100
}

0 commit comments

Comments
 (0)