aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache/file_store.rb
diff options
context:
space:
mode:
authorKohei Suzuki <eagletmt@gmail.com>2015-04-09 00:04:56 +0900
committerKohei Suzuki <eagletmt@gmail.com>2015-04-09 00:04:56 +0900
commit16d7cfb17788bdb9e3bd80d6403e98ac515e539c (patch)
treee821d5a79900a26db58ba40b6020eb50d2c0fb7b /activesupport/lib/active_support/cache/file_store.rb
parent0a120a818d413c64ff9867125f0b03788fc306f8 (diff)
downloadrails-16d7cfb17788bdb9e3bd80d6403e98ac515e539c.tar.gz
rails-16d7cfb17788bdb9e3bd80d6403e98ac515e539c.tar.bz2
rails-16d7cfb17788bdb9e3bd80d6403e98ac515e539c.zip
Allow AS::Cache::FileStore#clear without cache directory
Currently `Rails.cache.clear` raises Errno::ENOENT if it's run just after cloning a new Rails project. It should succeed without removing files or directories.
Diffstat (limited to 'activesupport/lib/active_support/cache/file_store.rb')
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index d08ecd2f7d..e6a8b84214 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -29,6 +29,7 @@ module ActiveSupport
def clear(options = nil)
root_dirs = Dir.entries(cache_path).reject {|f| (EXCLUDED_DIRS + [".gitkeep"]).include?(f)}
FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)})
+ rescue Errno::ENOENT
end
# Preemptively iterates through all stored keys and removes the ones which have expired.