-
Notifications
You must be signed in to change notification settings - Fork 467
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
fix: check directory before call delete on iOS #1066
fix: check directory before call delete on iOS #1066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this fix!
@@ -869,8 +869,14 @@ - (BOOL)_passthroughDelegate | |||
|
|||
[_manifest removeAllObjects]; | |||
[RCTGetCache() removeAllObjects]; | |||
NSDictionary *error = RCTDeleteStorageDirectory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be simpler if we check whether error.code == NSFileNoSuchFileError
in RCTDeleteStorageDirectory()
and ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it works and is also more clean, thanks for that.
I'm kinda new on Objective-C, I only return nil to ignore, if it was better to return another thing I could change again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again. I left only a minor nitpick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
🎉 This PR is included in version 1.22.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Before executing the
clear
method on iOS, check if the directory exists usingRCTGetStorageDirectory
to avoid throwing an error.Fixes #1020
Test Plan
To test this change I created an app from scratch and call
await AsyncStorage.clear()
.The component code is available on gist
before:
before.mp4
after:
after.mp4