Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-1316

Lose contents of localStorage if backed up while Journal emptying: "Error: database disk image is malformed"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: 1.8.1
    • Fix Version/s: 2.1.0
    • Component/s: None
    • Environment:

      iOS 5.1+

      Description

      The v1.6.1 workaround/fix CB-330 for iOS 5.1's localStorage iCloud-related file-deletion allows me to use localStorage in my app. However localStorage is sporadically and thereafter persistently blank when I relaunch my application.

      Further, when I Download the application via Xcode Organizer to my Mac and open it using SQLITE3 the database is reported to be corrupt: "Error: database disk image is malformed" is what sqlite says. This is seen in (xcappdata)/AppData/Documents/Backups/localstorage.appdata.db as well as AppData/Library/Caches/file__0.localstorage, after an app exit and restart. Sometimes I must time things to rapidly exit after using localStorage in the app (writing to the database) for this situation to occur. Also my application is set to exit when the user backgrounds it, via the info.plist "Application does not run in background" (aka UIApplicationExitsOnSuspend = YES) setting.

      I expect the localStorage DB to not be corrupted / blank when I resume my application.

      I once saw a SQLITE DB Journal file show up: AppData/Library/Caches/file__0.localstorage.journal in Xcode's Organizer window while I was using my app. This got me thinking that Cordova's https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVLocalStorage.m CB-330 implementation needs a tweak: wait to perform the backup until after the Journal file has been written. I figure if Cordova backs-up the database while the Journal is still being emptied then we'll get a corrupted localStorage!

      Thank you,
      Nick

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ncr100 Nick Richards
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: