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

Non Unique Pathnames generated in [RNCachingURLProtocol cachePathForRequest] #14

Open
ghost opened this issue Dec 5, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 5, 2012

When my web-application was in online mode, everything ran perfect. Everytime the CacheWebView ran in offline mode (all files were retrieved from cache only), my web-application encountered crazy behaviours like the assets of similiar visualisations were confused/mixed up,

While analyzing the runtime behaviour of the cache, I discovered the following issue:

The method "- (NSString *)cachePathForRequest:(NSURLRequest *)aRequest" sometimes produces non unique filenames. I found out about that by "NSLog(@"%@, %@\n", [[aRequest URL] absoluteString], fileName)" where fileName represents the generated path filename using [NString hash].

I managed to isolate the problem and located the problem as the use of [NSString hash].

[@"http://192.168.1.157/schmitz-web/assets/img/colorizer/models/medimatic_gyn/polster_pergament.png?cacheToken=1" hash]
[@"http://192.168.1.157/schmitz-web/assets/img/colorizer/models/medimatic_uro/polster_pergament.png?cacheToken=1 " hash]

Will result into the same hash value.
Further details on that can be found here: http://www.abakia.de/blog/blog/2012/12/05/nsstring-hash-is-bad/

I will supply a pull request for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants