1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make FileStore use atomic writes

This commit is contained in:
Joshua Peek 2008-08-06 14:52:39 -05:00
parent e5b1ab7cc3
commit dfc83566b3

View file

@ -15,7 +15,7 @@ module ActiveSupport
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