Skip to content

Commit

Permalink
Merge pull request #4452 from tapajos/e5425c8f68fbb720fcbf4b14e1f154a…
Browse files Browse the repository at this point in the history
…c27dbbbed

Fix cache (FileStore) clear to keep .gitkeep.
  • Loading branch information
tenderlove committed May 3, 2012
2 parents b55b77f + e5425c8 commit 7a3e43c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/cache/file_store.rb
Expand Up @@ -23,7 +23,7 @@ def initialize(cache_path, options = nil)
end end


def clear(options = nil) 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)}) FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)})
end end


Expand Down
7 changes: 7 additions & 0 deletions activesupport/test/caching_test.rb
Expand Up @@ -568,6 +568,13 @@ def cache_dir
include CacheDeleteMatchedBehavior include CacheDeleteMatchedBehavior
include CacheIncrementDecrementBehavior 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 def test_key_transformation
key = @cache.send(:key_file_path, "views/index?id=1") key = @cache.send(:key_file_path, "views/index?id=1")
assert_equal "views/index?id=1", @cache.send(:file_path_key, key) assert_equal "views/index?id=1", @cache.send(:file_path_key, key)
Expand Down

0 comments on commit 7a3e43c

Please sign in to comment.