method

save_data_with_atomic_file_rename_strategy

Importance_0
save_data_with_atomic_file_rename_strategy(data, file) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/pstore.rb, line 480
  def save_data_with_atomic_file_rename_strategy(data, file)
    temp_filename = "#{@filename}.tmp.#{Process.pid}.#{rand 1000000}"
    temp_file = File.new(temp_filename, WR_ACCESS)
    begin
      temp_file.flock(File::LOCK_EX)
      temp_file.write(data)
      temp_file.flush
      File.rename(temp_filename, @filename)
    rescue
      File.unlink(temp_file) rescue nil
      raise
    ensure
      temp_file.close
    end
  end
Register or log in to add new notes.