@@ -146,6 +146,13 @@ object zip {
146146 ! isExcluded && isIncluded
147147 }
148148
149+ private def toFileType (file : os.Path ): apache.PermissionUtils .FileType = {
150+ if (os.isLink(file)) apache.PermissionUtils .FileType .SYMLINK
151+ else if (os.isFile(file)) apache.PermissionUtils .FileType .REGULAR_FILE
152+ else if (os.isDir(file)) apache.PermissionUtils .FileType .DIR
153+ else apache.PermissionUtils .FileType .OTHER
154+ }
155+
149156 private def makeZipEntry (
150157 file : os.Path ,
151158 sub : os.SubPath ,
@@ -158,8 +165,8 @@ object zip {
158165 zipEntry.setTime(mtime)
159166
160167 val mode = apache.PermissionUtils .modeFromPermissions(
161- os.perms(file).toSet(),
162- apache. PermissionUtils . FileType .of (file.toNIO )
168+ os.perms(file, followLinks = false ).toSet(),
169+ toFileType (file)
163170 )
164171 zipEntry.setUnixMode(mode)
165172
@@ -280,6 +287,7 @@ object unzip {
280287 val target = scala.io.Source .fromInputStream(zipInputStream).mkString
281288 val path = java.nio.file.Paths .get(target)
282289 val dest = if (path.isAbsolute) os.Path (path) else os.RelPath (path)
290+ os.makeDir.all(newFile / os.up)
283291 os.symlink(newFile, dest)
284292 } else {
285293 val outputStream = os.write.outputStream(newFile, createFolders = true )
0 commit comments