diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-09-06 14:49:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 14:49:26 -0400 |
commit | 4b010b081592ba3af3253b50c76496c43c26a635 (patch) | |
tree | 1ddb96e6f69fdc13096efe116cd3beac44f2919e /activesupport | |
parent | 1c59b4840c58097186022f68427c46e0046c5d0d (diff) | |
parent | 8eb3cd8e56eacb9e0054326a0c0545a7b64c1c22 (diff) | |
download | rails-4b010b081592ba3af3253b50c76496c43c26a635.tar.gz rails-4b010b081592ba3af3253b50c76496c43c26a635.tar.bz2 rails-4b010b081592ba3af3253b50c76496c43c26a635.zip |
Merge pull request #33805 from schneems/schneems/faster-file-store
Faster File Store
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index a0f44aac0f..04c54c30d0 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -127,15 +127,19 @@ module ActiveSupport hash = Zlib.adler32(fname) hash, dir_1 = hash.divmod(0x1000) dir_2 = hash.modulo(0x1000) - fname_paths = [] # Make sure file name doesn't exceed file system limits. - begin - fname_paths << fname[0, FILENAME_MAX_SIZE] - fname = fname[FILENAME_MAX_SIZE..-1] - end until fname.blank? + if fname.length < FILENAME_MAX_SIZE + fname_paths = fname + else + fname_paths = [] + begin + fname_paths << fname[0, FILENAME_MAX_SIZE] + fname = fname[FILENAME_MAX_SIZE..-1] + end until fname.blank? + end - File.join(cache_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, *fname_paths) + File.join(cache_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, fname_paths) end # Translate a file path into a key. |