Skip to content

Commit

Permalink
fix issue with mkdir failing to create directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakenelf committed Sep 12, 2021
1 parent f72eb1c commit 8172761
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions directory/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package directory

import (
"archive/zip"
"errors"
"fmt"
"io"
"io/fs"
Expand All @@ -20,16 +21,14 @@ func RenameDirOrFile(src, dst string) error {

// CreateDirectory creates a new directory given a name.
func CreateDirectory(name string) error {
_, err := os.Stat(name)

// If the directory does not already exist, create it.
if os.IsNotExist(err) {
if err := os.MkdirAll(name, 0755); err != nil {
if _, err := os.Stat(name); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(name, os.ModePerm)
if err != nil {
return err
}
}

return err
return nil
}

// GetDirectoryListing returns a list of files and directories within a given directory.
Expand Down

0 comments on commit 8172761

Please sign in to comment.