vendor/rails/activesupport/lib/active_support/cache/file_store.rb in radiant-0.7.2 vs vendor/rails/activesupport/lib/active_support/cache/file_store.rb in radiant-0.8.0

- old
+ new

@@ -1,25 +1,27 @@ module ActiveSupport module Cache + # A cache store implementation which stores everything on the filesystem. class FileStore < Store attr_reader :cache_path def initialize(cache_path) @cache_path = cache_path end def read(name, options = nil) super - File.open(real_file_path(name), 'rb') { |f| f.read } rescue nil + File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil end 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), cache_path) { |f| Marshal.dump(value, f) } + value rescue => e - RAILS_DEFAULT_LOGGER.error "Couldn't create cache directory: #{name} (#{e.message})" if RAILS_DEFAULT_LOGGER + logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger end def delete(name, options = nil) super File.delete(real_file_path(name)) @@ -63,8 +65,8 @@ else callback.call name end end end - end + end end -end \ No newline at end of file +end