Skip to content

Recovering from pre-1.2.2 versions #55

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

Closed
krizzu opened this issue Apr 3, 2019 · 3 comments
Closed

Recovering from pre-1.2.2 versions #55

krizzu opened this issue Apr 3, 2019 · 3 comments
Labels
enhancement New feature or request platform: iOS This is iOS specific question General question about usage

Comments

@krizzu
Copy link
Member

krizzu commented Apr 3, 2019

What's going on?

It came to my attention that I've introduced a Breaking change, without properly announcing it.

This is only related to iOS platform. Since version 1.0.2, location where Async Storage kept files was changed: 34fb665

Some time age, issue #40 was raised, saying that smooth transition from Core's Async Storage to Community's was not possible, as data was lost on migration (actually, stored somewhere else). I've merged a fix in #46, to bring back the compatibility.

Now, devs that already transitioned to this repo (pre v1.2.2), planning to upgrade to the latest (v1.2.2), would be left off with the same issue as before - their current local data would not be accessible again.

I can imagine how this can be frustrating, to see no breaking change note in the changelog, yet experiencing different module behavior than expected. If this is a case that you got into - I'm sorry, the blame is all mine.

What now?

I wanted to discuss a way to fix this issue, and give pre-v1.2.2 devs ability to upgrade to next versions, without breaking anything on the way.

To make this work, we need to move manifest.json file from old (RNCAsyncLocalStorage_V1) directory to a new, correct one (RCTAsyncLocalStorage_V1), deleting unnecessary folder afterwards. This will ensure that data will be kept and in the right directory.


// pseudo native code

fun migrateToAsyncStorage() {
    let oldDir = Dir('RNCAsyncLocalStorage_V1')
    let newDir = Dir('RCTAsyncLocalStorage_V1')

    if(oldDir.exists) {
        moveManifest(oldDir, newDir);
        deleteDir(oldDir);
    }
}

This could be introduced as Native Module or just a simple check on iOS side, when module is build.

Any feedback as always is appreciated, please let me know what you think.

thanks.

@krizzu krizzu added enhancement New feature or request question General question about usage platform: iOS This is iOS specific labels Apr 3, 2019
@reilem
Copy link
Contributor

reilem commented Apr 8, 2019

We can execute something at module instantiation by including this code.

@implementation RNCAsyncStorage
{
...
}
...
+ (BOOL)requiresMainQueueSetup {
    return YES;
}

- (instancetype)init
{
    if (!(self = [super init])) {
        return nil;
    }
    // EXECUTE CODE HERE
    return self;
}
...
@end

Now my only "trouble" is finding a clean way to re-use the directory path creation method RCTGetStorageDirectory since it uses a dispatch_once. I don't want duplicate code, but I think I found a way to do it. I'll maybe make a PR soon with an initial proposal and we can work from there. Unless you are currently working on any ideas?

@krizzu
Copy link
Member Author

krizzu commented Apr 9, 2019

Hey @reilem,

I've checked your implementation at your branch and I like it better. Happy to accept PR with it.

thanks.

@krizzu
Copy link
Member Author

krizzu commented Apr 12, 2019

Fixed within v1.3.1 release 🎉

@krizzu krizzu closed this as completed Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform: iOS This is iOS specific question General question about usage
Projects
None yet
Development

No branches or pull requests

2 participants