Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix permission problems while unzipping
  • Loading branch information
facchinm authored and cmaglie committed Jan 11, 2018
commit e3a30966b139a876cbc3fcdeb6b111ef1f691786
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