lib/xamplr/persisters/filesystem.rb in xamplr-1.2.0 vs lib/xamplr/persisters/filesystem.rb in xamplr-1.3.15
- old
+ new
@@ -23,11 +23,10 @@
catch(:refuse_to_version) do
Version.new(@repo_name, @repo_root).make(stream)
end
end
-
def write(xampl)
#raise XamplException.new(:no_index_so_no_persist) unless xampl.get_the_index or xampl.ignore_when_no_index
raise XamplException.new("no_index_so_no_persist [#{xampl.class.name}]") unless xampl.get_the_index or xampl.ignore_when_no_index
return unless xampl.get_the_index
@@ -37,10 +36,17 @@
place = File.join(place, xampl.get_the_index)
representation = represent(xampl)
if representation then
- File.open(place, "w"){ | out | out.puts representation }
+ File.open(place, "w")do |out|
+ out.puts representation
+ out.fsync
+ if $is_darwin then
+ out.fcntl(51, 0) # Attempt an F_FULLFSYNC fcntl to commit data to disk
+ end
+
+ end
@write_count = @write_count + 1
end
xampl.changes_accepted
return true
end