提交 dfc83566 编写于 作者: J Joshua Peek

Make FileStore use atomic writes

上级 e5b1ab7c
......@@ -15,7 +15,7 @@ def read(name, options = nil)
def write(name, value, options = nil)
super
ensure_cache_path(File.dirname(real_file_path(name)))
File.open(real_file_path(name), "wb+") { |f| f.write(value) }
File.atomic_write(real_file_path(name)) { |f| f.write(value) }
rescue => e
RAILS_DEFAULT_LOGGER.error "Couldn't create cache directory: #{name} (#{e.message})" if RAILS_DEFAULT_LOGGER
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册