mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #3174 from phuibonhoa/master
Fixed file store to handle delete_matched being called before cache dir is created.
This commit is contained in:
commit
1efe41dc36
2 changed files with 9 additions and 0 deletions
|
@ -161,6 +161,7 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def search_dir(dir, &callback)
|
||||
return if !File.exist?(dir)
|
||||
Dir.foreach(dir) do |d|
|
||||
next if d == "." || d == ".."
|
||||
name = File.join(dir, d)
|
||||
|
|
|
@ -566,6 +566,14 @@ class FileStoreTest < ActiveSupport::TestCase
|
|||
assert path.split('/').all? { |dir_name| dir_name.size <= ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE}
|
||||
assert_equal 'B', File.basename(path)
|
||||
end
|
||||
|
||||
# If nothing has been stored in the cache, there is a chance the cache directory does not yet exist
|
||||
# Ensure delete_matched gracefully handles this case
|
||||
def test_delete_matched_when_cache_directory_does_not_exist
|
||||
assert_nothing_raised(Exception) do
|
||||
ActiveSupport::Cache::FileStore.new('/test/cache/directory').delete_matched(/does_not_exist/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MemoryStoreTest < ActiveSupport::TestCase
|
||||
|
|
Loading…
Reference in a new issue