lib/zold/node/farm.rb in zold-0.11.6 vs lib/zold/node/farm.rb in zold-0.11.7

- old
+ new

@@ -20,10 +20,11 @@ require 'time' require_relative '../log' require_relative '../score' require_relative '../verbose_thread' +require_relative '../atomic_file' # The farm of scores. # Author:: Yegor Bugayenko (yegor256@gmail.com) # Copyright:: Copyright (c) 2018 Yegor Bugayenko # License:: MIT @@ -103,10 +104,10 @@ end private def save(score) - File.write(@cache, (history + [score]).map(&:to_s).join("\n")) + AtomicFile.new(@cache).write((history + [score]).map(&:to_s).join("\n")) end def history(max = 16) if File.exist?(@cache) File.readlines(@cache)