You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Christian Hemker (JIRA)" <ji...@apache.org> on 2012/09/28 21:23:07 UTC

[jira] [Commented] (CB-1558) LocalStorage is lost after upgrade to cordova 2.1 and ios6 up from from ios5

    [ https://issues.apache.org/jira/browse/CB-1558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13465840#comment-13465840 ] 

Christian Hemker commented on CB-1558:
--------------------------------------

This problem happens if you have created an App (the old Version of your app),
which stores the LocalStorage into the Default Location under iOS 5 <iOS App Directory>/Library/Caches/file__0.localstorage
There you have already the Problem with iOS 5.1.x, that the Caches Directory can be deleted, when iOS is running out of space.

I had the same problem with the old version of my app with cordova 2.1 and iOS 6.
If you like, you can use this fix for that.

{code:title=CDVLocalStorage.m Line 69}

    // ////////// LOCALSTORAGE
    NSString* original;
    NSString* backup;
    
    if(IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0") ){
        // 5.1 <= running iOS Version < 6.0
        original = [[appLibraryFolder stringByAppendingPathComponent:@"Caches"]stringByAppendingPathComponent:@"file__0.localstorage"];
        NSLog(@"createBackupInfo iOS 5.1 original:%@", original);
        
        backup = [backupsFolder stringByAppendingPathComponent:@"localstorage.appdata.db"];
        NSLog(@"createBackupInfo iOS 5.1 backup:%@", backup);
    } else {
        // iOS Version >= 6.0
        original = [[appLibraryFolder stringByAppendingPathComponent:@"WebKit/LocalStorage"] stringByAppendingPathComponent:@"file__0.localstorage"];
        NSLog(@"createBackupInfo iOS 6 original:%@", original);

        backup = [[appLibraryFolder stringByAppendingPathComponent:@"Caches"] stringByAppendingPathComponent:@"file__0.localstorage"];
        NSLog(@"createBackupInfo use Caches folder to save in WebKit directory backup:%@", backup);
    }
    
    CDVBackupInfo* backupItem = [[CDVBackupInfo alloc] init];
    backupItem.backup = backup;
    backupItem.original = original;
    backupItem.label = @"localStorage database";

    [backupInfo addObject:backupItem];
{code}
                
> LocalStorage is lost after upgrade to cordova 2.1 and ios6 up from from ios5
> ----------------------------------------------------------------------------
>
>                 Key: CB-1558
>                 URL: https://issues.apache.org/jira/browse/CB-1558
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.1.0
>            Reporter: Michal Mocny
>            Assignee: Michal Mocny
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> 1. Create an app with ios5 which uses web storage.
> 2. Upgrade that app to use cordova 2.1 and ios6.
> 3. See that web storage resets.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira