diff options
author | Adam Panzer <apanzerj@gmail.com> | 2014-06-10 10:53:48 -0700 |
---|---|---|
committer | Adam Panzer <apanzerj@gmail.com> | 2014-06-10 10:53:48 -0700 |
commit | 9010274627a538c688e44737e7a50c659da7e863 (patch) | |
tree | 98e86aa8c8612b3b7ff3bd5bed47032b60f7ed7b /activesupport/lib/active_support/cache | |
parent | 3681e1ac2c5448b9826f2e3c9b6508c50d2b4f17 (diff) | |
download | rails-9010274627a538c688e44737e7a50c659da7e863.tar.gz rails-9010274627a538c688e44737e7a50c659da7e863.tar.bz2 rails-9010274627a538c688e44737e7a50c659da7e863.zip |
fix error with long keys in ActiveSupport::Cache::FileStore
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 8ed60aebac..d08ecd2f7d 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -14,6 +14,7 @@ module ActiveSupport DIR_FORMATTER = "%03X" FILENAME_MAX_SIZE = 228 # max filename size on file system is 255, minus room for timestamp and random characters appended by Tempfile (used by atomic write) + FILEPATH_MAX_SIZE = 900 # max is 1024, plus some room EXCLUDED_DIRS = ['.', '..'].freeze def initialize(cache_path, options = nil) @@ -117,6 +118,10 @@ module ActiveSupport # Translate a key into a file path. def key_file_path(key) + if key.size > FILEPATH_MAX_SIZE + key = Digest::MD5.hexdigest(key) + end + fname = URI.encode_www_form_component(key) hash = Zlib.adler32(fname) hash, dir_1 = hash.divmod(0x1000) |