Skip to content

Commit

Permalink
Merge pull request #127 from criteo/fix-unzip-permission
Browse files Browse the repository at this point in the history
Fix unzip package folder permission
  • Loading branch information
gmonceyron authored Oct 13, 2023
2 parents fed777f + 0f88602 commit 3690386
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/pkg/zip-package.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ func (pkg *zipPackage) InstallTo(targetDir string) (command.PackageManifest, err
extractedFilePath := filepath.Join(targetDir, file.Name)
if file.FileInfo().IsDir() {
log.Println("Directory Created:", extractedFilePath)
err := os.MkdirAll(extractedFilePath, file.Mode())
if err != nil {
return nil, fmt.Errorf("directory extraction failed: %s", err)
if os.Stat(extractedFilePath); os.IsNotExist(err) {
// create the folder if it does not exist
err := os.MkdirAll(extractedFilePath, 0755)
if err != nil {
return nil, fmt.Errorf("directory extraction failed: %s", err)
}
} else {
// chmod to 755
if err := os.Chmod(extractedFilePath, 0755); err != nil {
return nil, fmt.Errorf("failed to chmod %s to 0755: %s", extractedFilePath, err)
}
}
} else {
log.Println("File extracted:", file.Name)
Expand Down

0 comments on commit 3690386

Please sign in to comment.