From 16d7cfb17788bdb9e3bd80d6403e98ac515e539c Mon Sep 17 00:00:00 2001 From: Kohei Suzuki Date: Thu, 9 Apr 2015 00:04:56 +0900 Subject: 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. --- activesupport/lib/active_support/cache/file_store.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport/lib/active_support/cache/file_store.rb') 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. -- cgit v1.2.3