-
Notifications
You must be signed in to change notification settings - Fork 473
iOS clean migration from RNCAsyncStorage_V1 to RTCAsyncStorage_V1 #64
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
Conversation
Hey @reilem, thanks for your work! |
ios/RNCAsyncStorage.m
Outdated
if (!newStorageDirectoryExists) { | ||
// If new storage direction doesn't exist, copy old storage directory to new location | ||
if (![[NSFileManager defaultManager] copyItemAtPath:RCTCreateStorageDirectoryPath(OldStorageDirectory) toPath:RCTGetStorageDirectory() error:&error]) { | ||
@throw RCTStorageDirectionMigrationException(@"Failed to copy old storage directory to new storage directory", error); |
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.
We probably shouldn't take down the whole app if we fail to migrate. I think in the rare cases where IO might fail, maybe it's probably fine to just say that we "lost" the data?
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 I am not a big fan of crashing the app either, but I'm not a fan of leaving errors unused either. I guess in this case it would be just fine to ignore the errors? Cause I don't think adding NSLog
s will be of much use either.
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 there's also a real risk of going into a crash loop. I think we should ignore it, and use RCTLogWarn or RCTLogError to log errors. What do you think, @krizzu?
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.
Ah cool, didn't know these existed. Errors would also cause app crashes so I guess we could go with the Warnings to be safe. Right now I've replaced everything with NSLogs for now, so let me know what you guys think is best.
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 I prefer RCTLogWarn
because they will at least be visible during debug as a yellow box, in addition to being logged to the console.
@tido64 Thanks for having a look. @reilem Thank you for your work 💪 On a second though, simply deleting Say, someone used pre-1.2.2 AS, then upgrades to 1.2.3/4 ( I like the approach that @tido64 suggested, to check when each of the files (from RNC and RTC) were accessed and based on that proceed with migration. Something like that:
Let me know what you think! |
I've made the requested changes however I have encountered a strange issue during testing. While the Aside from the above issue, I have debugged the flow of the migration in the four cases and they seem to be working:
|
@reilem Hey, This strange behavior might come from the regression we had on iOS in version 1.2.3 and 1.2.4. Please rebase with latest master and check if it works for you and let me know. |
I think I discovered my issue, during refactoring I made the manifest file path using |
* Use const and RCT prefix for RCTOldStorageDirectory * Log errors instead of throwing exceptions * Disable main queue setup
I have rebased on the latest PR merge, fixed the manifest issue and now use |
Looking good! Going to test it manually later today to confirm it from my side. thanks. |
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 the good work! Code looks good to me. Just one little nitpick 😛
I haven't tested it yet. Maybe I have some time later today if @krizzu hasn't done it already 👍
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.
## [1.3.1](v1.3.0...v1.3.1) (2019-04-12) ### Bug Fixes * iOS clean migration from RNCAsyncStorage_V1 to RTCAsyncStorage_V1 ([#64](#64)) ([8d275ad](8d275ad))
🎉 This PR is included in version 1.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [1.3.1](react-native-async-storage/async-storage@v1.3.0...v1.3.1) (2019-04-12) ### Bug Fixes * iOS clean migration from RNCAsyncStorage_V1 to RTCAsyncStorage_V1 ([#64](react-native-async-storage/async-storage#64)) ([8d275ad](react-native-async-storage/async-storage@8d275ad))
## [1.3.1](react-native-async-storage/async-storage@v1.3.0...v1.3.1) (2019-04-12) ### Bug Fixes * iOS clean migration from RNCAsyncStorage_V1 to RTCAsyncStorage_V1 ([#64](react-native-async-storage/async-storage#64)) ([8d275ad](react-native-async-storage/async-storage@8d275ad))
Summary:
See: #55
Test Plan:
The only type of tests I have already run is:
RCTStorageDirectory
toRNCAsyncStorage_V1
RCTStorageDirectory
toRCTAsyncStorage_V1
I have performed these tests with and without a pre-existing storage directory and they work in both cases.
My only concerns are the way I am currently handling errors. If something goes wrong an
NSException
is thrown which will trigger a SIGABRT shutdown of the app since it is never caught. I am not extremely experienced with error handling in Objective-C so perhaps someone has some better ideas.