diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-03 15:56:54 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-05-03 15:56:54 -0700 |
commit | 7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00 (patch) | |
tree | fca445c985b6cdc4357eab1c945f6ba426efd2a1 /activesupport | |
parent | b55b77f1ef76a59db15ebe71ce28e070534a6d29 (diff) | |
parent | e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed (diff) | |
download | rails-7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00.tar.gz rails-7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00.tar.bz2 rails-7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00.zip |
Merge pull request #4452 from tapajos/e5425c8f68fbb720fcbf4b14e1f154ac27dbbbed
Fix cache (FileStore) clear to keep .gitkeep.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 2 | ||||
-rw-r--r-- | activesupport/test/caching_test.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 8e6a3bc5a8..e7316b23b3 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -23,7 +23,7 @@ module ActiveSupport end def clear(options = nil) - root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS)} + root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS + [".gitkeep"])} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 5365713e6e..bb9ce23276 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -568,6 +568,13 @@ class FileStoreTest < ActiveSupport::TestCase include CacheDeleteMatchedBehavior include CacheIncrementDecrementBehavior + def test_clear + filepath = File.join(cache_dir, ".gitkeep") + FileUtils.touch(filepath) + @cache.clear + assert File.exist?(filepath) + end + def test_key_transformation key = @cache.send(:key_file_path, "views/index?id=1") assert_equal "views/index?id=1", @cache.send(:file_path_key, key) |