lib/zold/node/farm.rb in zold-0.14.52 vs lib/zold/node/farm.rb in zold-0.14.53
- old
+ new
@@ -25,11 +25,10 @@
require 'backtrace'
require_relative '../log'
require_relative '../score'
require_relative '../age'
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
@@ -220,11 +219,12 @@
def save(threads, list = [])
scores = load + list
period = 24 * 60 * 60 / [threads, 1].max
@mutex.synchronize do
- AtomicFile.new(@cache).write(
+ File.write(
+ @cache,
scores.select(&:valid?)
.reject(&:expired?)
.sort_by(&:value)
.reverse
.uniq(&:time)
@@ -237,10 +237,10 @@
end
def load
@mutex.synchronize do
if File.exist?(@cache)
- AtomicFile.new(@cache).read.split(/\n/)
+ File.read(@cache).split(/\n/)
.map { |t| parse_score_line(t) }
.reject(&:zero?)
else
[]
end