From 2acaaff801a93414d3fb3d1d3a0f27aeec605ec7 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 18 Jul 2016 21:59:18 -0400 Subject: [PATCH] state_file: fsync and binmode --- lib/vagrant/plugin/state_file.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/plugin/state_file.rb b/lib/vagrant/plugin/state_file.rb index 516f7be1c..fc9060849 100644 --- a/lib/vagrant/plugin/state_file.rb +++ b/lib/vagrant/plugin/state_file.rb @@ -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