Skip to content

Commit

Permalink
Merge c4ce52c into b59030b
Browse files Browse the repository at this point in the history
  • Loading branch information
bpineau committed Apr 20, 2018
2 parents b59030b + c4ce52c commit ad847d5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/recorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,24 @@ func (w *Listener) save(file string, data []byte) error {
w.actives[w.relativePath(file)] = true
w.activesLock.Unlock()

err = afero.WriteFile(appFs, file, data, 0600)
tmpfile, err := afero.TempFile(appFs, "", "katafygio")
if err != nil {
return fmt.Errorf("failed to create a temporary file: %v", err)
}

_, err = tmpfile.Write(data)
if err != nil {
return fmt.Errorf("failed to write to %s on disk: %v", file, err)
}

if err := tmpfile.Close(); err != nil {
return fmt.Errorf("failed to close a temporary file: %v", err)
}

if err := appFs.Rename(tmpfile.Name(), file); err != nil {
return fmt.Errorf("failed to create %s: %v", file, err)
}

return nil
}

Expand Down

0 comments on commit ad847d5

Please sign in to comment.