-
Notifications
You must be signed in to change notification settings - Fork 377
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
prevent crash when disk cache file is corrupted #62
Conversation
Wouldn't a better approach be to figure out what is causing the exception rather than blindly wrapping a call in a try/catch block? |
Yeah, we were also investigating why the file is damaged. The situation is really rare but the crash reports did show up in our system. My best guess is the app might encountered a crash when writing to the disk cache previously. What makes me think it's necessary to add a try catch block is if the file is damaged, the app will always crash when reading from the cache. In my app, the reading happens right after launch, so affected users can no longer use my app. So I think it is better to at least prevent crash while we trying to discover the true cause of the problem. |
If the issue is indeed an incomplete write, it might be better to write out to a temp dir and atomically move the completed archive. |
We are using |
👍 We're having issues with this as well, and I was about to submit this same PR. We aren't able to replicate directly, but it shows up in the production crash logs. An issue was also filed for this, but closed because it couldn't be reproduced (#32).
I think it makes sense to protect against it here. |
Same here. 👍 |
+1 would love to see this implemented |
+1 that something should be done about this. The app can decide what to do w/ that "bad" data. This way we aren't blindly failing silently, and the app still has a way to recover. This is the #1 crash in our production app right now, and we can't do anything about it. |
Sorry for the delay – I agree that this is probably a good change to implement and will look into doing so shortly. |
prevent crash when disk cache file is corrupted
Thanks for your contribution, this has been released as part of TMCache 1.2.3. |
We have received several crash reports related to TMDiskCache like below:
It is because the users' cache file is somehow corrupted and It seems the line crashed
object = [NSKeyedUnarchiver unarchiveObjectWithFile:[fileURL path]];
needs a try catch block to prevent crash when this happens.