Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMDiskCache fails silently when keys are too long #31

Open
peyton opened this issue Jun 25, 2013 · 1 comment
Open

TMDiskCache fails silently when keys are too long #31

peyton opened this issue Jun 25, 2013 · 1 comment
Labels

Comments

@peyton
Copy link

peyton commented Jun 25, 2013

So if you try to store a file keyed by something like file://localhost/Users/peyton/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/DA12CB50-EA95-479D-BC14-7A01A68914B3/Documents/CameraCache/9EE8E76D-41A9-4226-974A-38D298F8971A-48969-00000C866AB57336.gif, TMDiskCache will fail silently. After URL encoding, the filename is waaay too long.

Inside <sys/syslimits.h>, there's NAME_MAX, the maximum length of the last component of a path, and PATH_MAX the absolute limit on path length.

I leave it to you to decide what to do.

@ghost ghost assigned jstn Jun 27, 2013
@ChristopherDrum
Copy link

How long is "too long"? I'm trying to find the root cause of my app's TMCache crash issues, but I'm not finding this to be a problem. I ran a test on TMCache to this effect in which I take the key passed into TMCache and make it 18x longer via

NSString *key = [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@", baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey, baseKey];

Then I logged out the byte size of each key being used. I got the following results, with no failures nor crashing:
fetching a 1800 byte long key
fetching a 1818 byte long key
fetching a 1800 byte long key
setting a 1908 byte long key
setting a 1710 byte long key
setting a 1890 byte long key
fetching a 1440 byte long key
fetching a 1440 byte long key
setting a 1818 byte long key
setting a 4986 byte long key
setting a 1440 byte long key
setting a 1674 byte long key
setting a 1818 byte long key
setting a 1800 byte long key
fetching a 1908 byte long key
fetching a 1710 byte long key

You can see these are exceptionally long keys, with one that is about 5K, let alone the file path it uses for storage. TMCache didn't flinch on any of these. Testing was done on-device (iPhone 6+, iOS 8.1.2)

@peyton peyton unassigned jstn Dec 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants