Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4452 from tapajos/e5425c8f68fbb720fcbf4b14e1f154a…

…c27dbbbed

Fix cache (FileStore) clear to keep .gitkeep.
  • Loading branch information...
commit 7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00 2 parents b55b77f + e5425c8
@tenderlove tenderlove authored
View
2  activesupport/lib/active_support/cache/file_store.rb
@@ -23,7 +23,7 @@ def initialize(cache_path, options = nil)
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
View
7 activesupport/test/caching_test.rb
@@ -568,6 +568,13 @@ def cache_dir
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)
Please sign in to comment.
Something went wrong with that request. Please try again.