Skip to content

Commit

Permalink
fix(utils): use permission in ensure-path-at (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Jan 9, 2024
1 parent 4541bc3 commit 431fb2b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions xfs/utils/ensure-path-at.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import (
"github.com/snivilised/extendio/xfs/storage"
)

// EnsurePathAt ensures that the specified path exists. Given a path and a default
// filename, the specified path is created in the following manner:
// - If the path denotes a file (path does not end is a directory separator), the
// EnsurePathAt ensures that the specified path exists (including any non
// existing intermediate directories). Given a path and a default filename,
// the specified path is created in the following manner:
// - If the path denotes a file (path does not end is a directory separator), then
// the parent folder is created if it doesn't exist on the file-system provided.
// - If the path denotes a directory, then that directory is created
// - If the path denotes a directory, then that directory is created.
//
// The returned string represents the file, so if the path specified was a path, then
// the defaultFilename provided is joined the the path and returned, otherwise
// the original path is returned un-modified.
// Note: filepath.Join does not preserve trailing separator, therefore to make sure
// The returned string represents the file, so if the path specified was a
// directory path, then the defaultFilename provided is joined to the path
// and returned, otherwise the original path is returned un-modified.
// Note: filepath.Join does not preserve a trailing separator, therefore to make sure
// a path is interpreted as a directory and not a file, then the separator has
// to be appended manually onto the end of the path.
// If vfs is not provided, then the path is ensured directly on the native file
Expand All @@ -36,7 +37,6 @@ func EnsurePathAt(path, defaultFilename string, perm int, vfs ...storage.Virtual

if len(vfs) > 0 {
if !vfs[0].DirectoryExists(directory) {
const perm = 0o766
err = vfs[0].MkdirAll(directory, os.FileMode(perm))
}
} else {
Expand Down

0 comments on commit 431fb2b

Please sign in to comment.