Try one more time after deleting corrupted database

This commit is contained in:
Ali 2023-01-07 15:15:56 +04:00
parent cfff49d6c0
commit 1aa0d30a08

View File

@ -363,7 +363,14 @@ public final class SqliteValueBox: ValueBox {
for fileName in dabaseFileNames {
let _ = try? FileManager.default.removeItem(atPath: basePath + "/\(fileName)")
}
database = Database(path, readOnly: false)!
let maybeDatabase = Database(path, readOnly: false)
if let maybeDatabase = maybeDatabase {
database = maybeDatabase
} else {
let _ = try? FileManager.default.removeItem(atPath: path)
database = Database(path, readOnly: false)!
}
resultCode = database.execute("PRAGMA cipher_plaintext_header_size=32")
assert(resultCode)