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 authored and cmaglie committed Jan 11, 2018
1 parent b3dd26f commit e3a3096
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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 utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,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 e3a3096

Please sign in to comment.