Skip to content
This repository
Browse code

Merge pull request #4452 from tapajos/e5425c8f68fbb720fcbf4b14e1f154a…

…c27dbbbed

Fix cache (FileStore) clear to keep .gitkeep.
  • Loading branch information...
commit 7a3e43cc58a2d5d00d3e9fa8c9ab5583ffa5cf00 2 parents b55b77f + e5425c8
Aaron Patterson authored May 03, 2012
2  activesupport/lib/active_support/cache/file_store.rb
@@ -23,7 +23,7 @@ def initialize(cache_path, options = nil)
23 23
       end
24 24
 
25 25
       def clear(options = nil)
26  
-        root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS)}
  26
+        root_dirs = Dir.entries(cache_path).reject{|f| f.in?(EXCLUDED_DIRS + [".gitkeep"])}
27 27
         FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)})
28 28
       end
29 29
 
7  activesupport/test/caching_test.rb
@@ -568,6 +568,13 @@ def cache_dir
568 568
   include CacheDeleteMatchedBehavior
569 569
   include CacheIncrementDecrementBehavior
570 570
 
  571
+  def test_clear
  572
+    filepath = File.join(cache_dir, ".gitkeep")
  573
+    FileUtils.touch(filepath)
  574
+    @cache.clear
  575
+    assert File.exist?(filepath)
  576
+  end
  577
+
571 578
   def test_key_transformation
572 579
     key = @cache.send(:key_file_path, "views/index?id=1")
573 580
     assert_equal "views/index?id=1", @cache.send(:file_path_key, key)

0 notes on commit 7a3e43c

Please sign in to comment.
Something went wrong with that request. Please try again.