Skip to content

Commit

Permalink
Fix permission problems while unzipping
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Mar 16, 2017
1 parent 6a65d44 commit 74e4bd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/arduino.cc/builder/sketch_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *SketchLoader) Run(ctx *types.Context) error {
dir, _ := ioutil.TempDir("", "arduino_sketch_zip_temp")
sketchLocation, err = utils.ExtractZip(sketchLocation, dir)
if err != nil {
return nil
panic(err)
}
mainSketchFileName := filepath.Base(sketchLocation) + ".ino"
sketchLocation = filepath.Join(sketchLocation, mainSketchFileName)
Expand Down
7 changes: 5 additions & 2 deletions src/arduino.cc/builder/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,12 @@ func ExtractZip(filePath string, location string) (string, error) {
for _, f := range r.File {
fullname := filepath.Join(location, strings.Replace(f.Name, "", "", -1))
if f.FileInfo().IsDir() {
os.MkdirAll(fullname, f.FileInfo().Mode().Perm())
os.MkdirAll(fullname, 0755)
} else {
os.MkdirAll(filepath.Dir(fullname), 0755)
_, err := os.Stat(filepath.Dir(fullname))
if err != nil {
os.MkdirAll(filepath.Dir(fullname), 0755)
}
perms := f.FileInfo().Mode().Perm()
out, err := os.OpenFile(fullname, os.O_CREATE|os.O_RDWR, perms)
if err != nil {
Expand Down

0 comments on commit 74e4bd8

Please sign in to comment.