rails/rails — Issue #4907: ENAMETOOLONG in ActiveSupport::Cache::FileStore
Author: Floppy
Created: 2012-02-06 15:39:52+00:00
State: open

If long cache keys are passed to FileStore, it shortens them to fit into the file system max filename length.

It does this by shortening them to 230 characters to allow for extra cruft added by TempFile during atomic write.

However, 230 characters is not short enough. If cache keys of length 229 or 230 are passed in, the total length is too long for the filesystem. The atomic write seems to add 27 characters to the file, in the form 20120206-78101-13kzdln.lock

This causes a Errno::ENAMETOOLONG to be raised if cache keys are 229 or 230 characters in length. FILENAME_MAX_SIZE should therefore be 228, not 230.

I've only tested this on OSX Lion under Ruby 1.9.2p290, I'm not sure about behaviour on other platforms. I will attach a test script.

ActiveSupport 3.1.3 is definitely affected, and to me it looks like the code is still the same in the current HEAD.