Skip to content
This repository was archived by the owner on Sep 6, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ type SnapshotResponse struct {
// save writes the snapshot to file.
func (ss *Snapshot) save() error {
// Open the file for writing.
file, err := os.OpenFile(ss.Path, os.O_CREATE|os.O_WRONLY, 0600)
tmpname := ss.Path + ".tmp"
file, err := os.OpenFile(tmpname, os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
return err
}
Expand Down Expand Up @@ -82,7 +83,7 @@ func (ss *Snapshot) save() error {
return err
}

return nil
return os.Rename(tmpname, ss.Path)
}

// remove deletes the snapshot file.
Expand Down