From 771ca79f74db1e5a19703ad92472515dbebb70c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 25 Oct 2011 22:22:43 +0200 Subject: Revert "Merge pull request #3395 from bdurand/fix_file_store_cleanup" Tests were failing on Travis-CI. This reverts commit 79d01a8f16e20c556a086a2f07e3ccb4400f9819, reversing changes made to b838570bd69ff13d677fb43e79f10d6f3168c696. --- .../lib/active_support/cache/file_store.rb | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index bc5d94b5a7..b431041b76 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -26,26 +26,11 @@ module ActiveSupport FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end - # Cleanup the cache by removing old entries. By default this will delete entries - # that haven't been accessed in one day. You can change this behavior by passing - # in a +not_accessed_in+ option. Any entry not accessed in that number of seconds - # in the past will be deleted. Alternatively, you can pass in +:expired_only+ with - # +true+ to only delete expired entries. def cleanup(options = nil) options = merged_options(options) - expired_only = options[:expired_only] - timestamp = Time.now - (options[:not_accessed_in] || 1.day.to_i) - search_dir(cache_path) do |fname| - if expired_only - key = file_path_key(fname) - entry = read_entry(key, options) - delete_entry(key, options) if entry && entry.expired? - else - if File.atime(fname) <= timestamp - key = file_path_key(fname) - delete_entry(key, options) - end - end + each_key(options) do |key| + entry = read_entry(key, options) + delete_entry(key, options) if entry && entry.expired? end end -- cgit v1.2.3