Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1810333: daemon: Always create tempfiles in target dir #1530

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ func writeFileAtomicallyWithDefaults(fpath string, b []byte) error {
// writeFileAtomically uses the renameio package to provide atomic file writing, we can't use renameio.WriteFile
// directly since we need to 1) Chown 2) go through a buffer since files provided can be big
func writeFileAtomically(fpath string, b []byte, dirMode, fileMode os.FileMode, uid, gid int) error {
if err := os.MkdirAll(filepath.Dir(fpath), dirMode); err != nil {
dir := filepath.Dir(fpath)
if err := os.MkdirAll(dir, dirMode); err != nil {
return fmt.Errorf("failed to create directory %q: %v", filepath.Dir(fpath), err)
}
t, err := renameio.TempFile("", fpath)
t, err := renameio.TempFile(dir, fpath)
if err != nil {
return err
}
Expand Down