Details
Description
The backup and restore process for WebKit databases on iOS5.1 to copy databases from the /library/caches folder to /documents/backup is corrupting large databases.
I have a 1Gb sqllite databases, this is is because there will be a lot of data in the app and to get around the 5mb quota limit for Websql databases on iOS a large pre populated .db file is copied over to /library/caches on app start up in didFinishLaunchingWithOptions if it doesn't already exist. This 'reserves' the footprint of the database as sqlite doesn't unallocated space when deleting rows, the data is cleared out and the app can start off without any quota errors.
When the app terminates and the backup process runs to copy the .db file to /documents/backup it doesn't complete the process successfully (possibly killed by iOS before the file is fully written?) and the resulting file .db is much smaller (~200mb) and corrupt.
When the app runs next time the .db is copied from /documents/backup to /library/caches ok, but the damage is already done.