Skip to content

Commit

Permalink
Merge pull request moby#47664 from crazybolillo/47516-crazybolillo
Browse files Browse the repository at this point in the history
  • Loading branch information
cpuguy83 authored May 3, 2024
2 parents a73e63c + 57a12a3 commit ac71ac1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/ioutils/fswriters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// NewAtomicFileWriter returns WriteCloser so that writing to it writes to a
// temporary file and closing it atomically changes the temporary file to
// destination path. Writing and closing concurrently is not allowed.
// NOTE: umask is not considered for the file's permissions.
func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) {
f, err := os.CreateTemp(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
if err != nil {
Expand All @@ -26,7 +27,8 @@ func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, err
}, nil
}

// AtomicWriteFile atomically writes data to a file named by filename.
// AtomicWriteFile atomically writes data to a file named by filename and with the specified permission bits.
// NOTE: umask is not considered for the file's permissions.
func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error {
f, err := NewAtomicFileWriter(filename, perm)
if err != nil {
Expand Down

0 comments on commit ac71ac1

Please sign in to comment.