We have some code to determine if there is no database file currently created. If this is the case, we do some initialization routines to populate the user's database based on some files that may exist on the file system (basically a migration routine).
The routine is basically like this
NSURL * defaultStorePath = [NSPersistentStore MR_defaultLocalStoreUrl]; BOOL initializeDatabase = ![[NSFileManager defaultManager] fileExistsAtPath:[defaultStorePath path]]; [MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreAtURL:defaultStorePath]; if(initializeDatabase) // ... ingest user files ...
So this works well if the
.sqlite file is not present. However if the
.sqlite-shm files are missing/corrupt, we can't find a way to detect this scenario.
We would like to do a data integrity check or something in this case.