Handle SQLite corruption during database initialization
GRDB executes some simple statements when initializing a `DatabasePool` object (see [1][], [2][], [3][], [4][]). If any of those fail with a corruption error, we should flag the database as corrupted. This will let the user attempt recovery. [1]:23f4254ae3/GRDB/Core/Database.swift (L365)[2]:23f4254ae3/GRDB/Core/DatabasePool.swift (L75)[3]:23f4254ae3/GRDB/Core/DatabasePool.swift (L82)[4]:23f4254ae3/GRDB/Core/DatabasePool.swift (L91-L94)
This commit is contained in:
parent
fb8f390733
commit
dc9637b127
@ -110,6 +110,10 @@ public class GRDBDatabaseStorageAdapter: NSObject {
|
||||
// Crash if storage can't be initialized.
|
||||
storage = try GRDBStorage(dbURL: databaseFileUrl, keyspec: GRDBDatabaseStorageAdapter.keyspec)
|
||||
} catch {
|
||||
DatabaseCorruptionState.flagDatabaseCorruptionIfNecessary(
|
||||
userDefaults: CurrentAppContext().appUserDefaults(),
|
||||
error: error
|
||||
)
|
||||
owsFail("\(error.grdbErrorForLogging)")
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user