state_file: fsync and binmode

This commit is contained in:
Seth Vargo 2016-07-18 21:59:18 -04:00
parent ea17ad4530
commit 2acaaff801
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 3 additions and 1 deletions

View File

@ -94,9 +94,11 @@ module Vagrant
# This saves the state back into the state file.
def save!
Tempfile.open(@path.basename.to_s, @path.dirname.to_s) do |f|
f.binmode
f.write(JSON.dump(@data))
f.chmod(0644)
f.fsync
f.close
f.chmod(0644)
FileUtils.mv(f.path, @path)
end
end