method
save_data
v1_9_1_378 -
Show latest stable
-
0 notes -
Class: PStore
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
save_data(original_checksum, original_file_size, file)
private
Hide source
# File lib/pstore.rb, line 458 def save_data(original_checksum, original_file_size, file) # We only want to save the new data if the size or checksum has changed. # This results in less filesystem calls, which is good for performance. if marshal_dump_supports_canonical_option? new_data = Marshal.dump(@table, -1, true) else new_data = dump(@table) end new_checksum = Digest::MD5.digest(new_data) if new_data.size != original_file_size || new_checksum != original_checksum if @ultra_safe && !on_windows? # Windows doesn't support atomic file renames. save_data_with_atomic_file_rename_strategy(new_data, file) else save_data_with_fast_strategy(new_data, file) end end new_data.replace(EMPTY_STRING) end