Permalink
Browse files

helpers: Add a comment about file mode for new files

See #5434
  • Loading branch information...
bep committed Nov 14, 2018
1 parent 94f0f7e commit fabf026f4937bf6fbbb944aa7d6e721839ae4c92
Showing with 2 additions and 1 deletion.
  1. +2 −1 helpers/path.go
@@ -563,12 +563,13 @@ func OpenFilesForWriting(fs afero.Fs, filenames ...string) (io.WriteCloser, erro
func OpenFileForWriting(fs afero.Fs, filename string) (afero.File, error) {
filename = filepath.Clean(filename)
// Create will truncate if file already exists.
// os.Create will create any new files with mode 0666 (before umask).
f, err := fs.Create(filename)
if err != nil {
if !os.IsNotExist(err) {
return nil, err
}
if err = fs.MkdirAll(filepath.Dir(filename), 0777); err != nil { // rwx, rw, r before umask
if err = fs.MkdirAll(filepath.Dir(filename), 0777); err != nil { // before umask
return nil, err
}
f, err = fs.Create(filename)

0 comments on commit fabf026

Please sign in to comment.