File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -360,10 +360,10 @@ object unzip {
360360        } else  null 
361361
362362        if  (zipEntry.isDirectory) {
363-           os.makeDir.all(newFile, perms  =  perms )
364-           if  (perms !=  null   &&  os.perms(newFile)  !=  perms ) {
365-             //  because of umask 
366-             os.perms.set(newFile, perms)
363+           os.makeDir.all(newFile)
364+           if  (perms !=  null ) {
365+             //  make sure directories at least have OWNER_EXECUTE 
366+             os.perms.set(newFile, perms  +   PosixFilePermission . OWNER_EXECUTE )
367367          }
368368        } else  if  (isSymLink) {
369369          val  target  =  scala.io.Source .fromInputStream(zipInputStream).mkString
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import test.os.TestUtil.prep
55import  utest ._ 
66
77import  java .io .{ByteArrayInputStream , ByteArrayOutputStream , PrintStream }
8+ import  java .nio .file .attribute .PosixFilePermission 
89import  java .util .zip .{ZipEntry , ZipOutputStream }
910
1011object  ZipOpTests  extends  TestSuite  {
@@ -537,5 +538,25 @@ object ZipOpTests extends TestSuite {
537538      assert(file2Content ==  " Content of file2" 
538539    }
539540
541+     test(" unzipDirectoryEnsureExecutablePermission" -  prep { wd => 
542+       if  (! scala.util.Properties .isWin) {
543+         val  zipFileName  =  " zipDirExecutable" 
544+         val  source  =  wd /  " folder1" 
545+         val  dir  =  source /  " dir" 
546+ 
547+         os.makeDir(dir)
548+         val  perms  =  os.perms(dir)
549+         os.perms.set(dir, perms -  PosixFilePermission .OWNER_EXECUTE )
550+ 
551+         val  zipped  =  os.zip(
552+           dest =  wd /  s " $zipFileName.zip " ,
553+           sources =  Seq (source)
554+         )
555+ 
556+         val  unzipped  =  os.unzip(zipped, dest =  wd /  zipFileName)
557+         assert(os.perms(unzipped /  " dir" PosixFilePermission .OWNER_EXECUTE ))
558+         assert(os.perms(unzipped /  " dir" ==  perms)
559+       }
560+     }
540561  }
541562}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments