lib/perobs/TreeDB.rb in perobs-2.4.0 vs lib/perobs/TreeDB.rb in perobs-2.4.1
- old
+ new
@@ -26,10 +26,11 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'fileutils'
require 'perobs/Log'
+require 'perobs/RobustFile'
require 'perobs/DataBase'
require 'perobs/BTreeBlob'
module PEROBS
@@ -112,11 +113,11 @@
# @param hash [Hash] A Hash that maps String objects to strings or
# numbers.
def put_hash(name, hash)
file_name = File.join(@db_dir, name + '.json')
begin
- File.write(file_name, hash.to_json)
- rescue => e
+ RobustFile.write(file_name, hash.to_json)
+ rescue IOError => e
PEROBS.log.fatal "Cannot write hash file '#{file_name}': #{e.message}"
end
end
# Load the Hash with the given name.