Skip to content

Commit

Permalink
fixup: proper dir vs file
Browse files Browse the repository at this point in the history
  • Loading branch information
dpastoor committed Jun 11, 2022
1 parent 33ac4a7 commit ce8c98d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/unarchive/unarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ func Unarchive(input io.Reader, dir string) error {
fileName = trimTopDir(fileName)
}
newPath := filepath.Join(dir, fileName)
fdir := filepath.Dir(newPath)
if f.IsDir() {
dirMap[fdir] = true
dirMap[newPath] = true
return os.MkdirAll(newPath, f.Mode())
} else {
// check if we've seen the dir before, if not, we'll attemp to create
Expand All @@ -56,12 +55,13 @@ func Unarchive(input io.Reader, dir string) error {
// be the reason, and assume its probably the powershell compress-archive
// encantation, so rather than trying to go down that rabbit hole too far,
// some additional checking here
fdir := filepath.Dir(newPath)
_, seenDir := dirMap[fdir]
if !seenDir {
dirMap[fdir] = true
// linux default for new directories is 777 and let the umask handle
// if should have other controls
err := os.MkdirAll(newPath, 0777)
err := os.MkdirAll(fdir, 0777)
if err != nil {
return err
}
Expand Down

0 comments on commit ce8c98d

Please sign in to comment.