Skip to content

Commit

Permalink
Fsync all the things, all the time.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerebubuth committed Sep 7, 2016
1 parent 707bd75 commit bd63b8d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ class Replicator
fh.write(YAML.dump(@state))
end

# fsync the files in their old locations.
fsync(tmp_data)
fsync(tmp_state)

# sync the directory as well, to ensure that the file is reachable
# from the dirent and has been updated to account for any allocations.
fdirsync(File.dirname(tmp_data))
fdirsync(File.dirname(tmp_state))

# sanity check: the files we're moving into place
# should be non-empty.
raise "Temporary gzip file should exist, but doesn't." unless File.exist?(tmp_data)
Expand Down

0 comments on commit bd63b8d

Please sign in to comment.