[WIP] Quotes

This commit is contained in:
Ali
2023-10-13 15:24:53 +04:00
parent 50881b558f
commit a753d71cd7
46 changed files with 2076 additions and 606 deletions

View File

@@ -60,6 +60,7 @@ struct SqlitePreparedStatement {
if let path = pathToRemoveOnError {
postboxLog("Corrupted DB at step, dropping")
try? FileManager.default.removeItem(atPath: path)
postboxLogSync()
preconditionFailure()
}
}
@@ -84,6 +85,7 @@ struct SqlitePreparedStatement {
if let path = pathToRemoveOnError {
postboxLog("Corrupted DB at step, dropping")
try? FileManager.default.removeItem(atPath: path)
postboxLogSync()
preconditionFailure()
}
}
@@ -300,12 +302,14 @@ public final class SqliteValueBox: ValueBox {
} catch {
let _ = try? FileManager.default.removeItem(atPath: tempPath)
postboxLog("Don't have write access to database folder")
postboxLogSync()
preconditionFailure("Don't have write access to database folder")
}
if self.removeDatabaseOnError {
let _ = try? FileManager.default.removeItem(atPath: path)
}
postboxLogSync()
preconditionFailure("Couldn't open database")
}
@@ -577,6 +581,7 @@ public final class SqliteValueBox: ValueBox {
try? FileManager.default.removeItem(atPath: databasePath)
}
postboxLogSync()
preconditionFailure()
}
})
@@ -1197,6 +1202,7 @@ public final class SqliteValueBox: ValueBox {
let status = sqlite3_prepare_v3(self.database.handle, "INSERT INTO t\(table.table.id) (key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value", -1, SQLITE_PREPARE_PERSISTENT, &statement, nil)
if status != SQLITE_OK {
let errorText = self.database.currentError() ?? "Unknown error"
postboxLogSync()
preconditionFailure(errorText)
}
let preparedStatement = SqlitePreparedStatement(statement: statement)
@@ -1211,6 +1217,7 @@ public final class SqliteValueBox: ValueBox {
let status = sqlite3_prepare_v3(self.database.handle, "INSERT INTO t\(table.table.id) (key, value) VALUES(?, ?)", -1, SQLITE_PREPARE_PERSISTENT, &statement, nil)
if status != SQLITE_OK {
let errorText = self.database.currentError() ?? "Unknown error"
postboxLogSync()
preconditionFailure(errorText)
}
let preparedStatement = SqlitePreparedStatement(statement: statement)
@@ -1250,6 +1257,7 @@ public final class SqliteValueBox: ValueBox {
let status = sqlite3_prepare_v3(self.database.handle, "INSERT INTO t\(table.table.id) (key, value) VALUES(?, ?) ON CONFLICT(key) DO NOTHING", -1, SQLITE_PREPARE_PERSISTENT, &statement, nil)
if status != SQLITE_OK {
let errorText = self.database.currentError() ?? "Unknown error"
postboxLogSync()
preconditionFailure(errorText)
}
let preparedStatement = SqlitePreparedStatement(statement: statement)
@@ -1264,6 +1272,7 @@ public final class SqliteValueBox: ValueBox {
let status = sqlite3_prepare_v3(self.database.handle, "INSERT INTO t\(table.table.id) (key, value) VALUES(?, ?)", -1, SQLITE_PREPARE_PERSISTENT, &statement, nil)
if status != SQLITE_OK {
let errorText = self.database.currentError() ?? "Unknown error"
postboxLogSync()
preconditionFailure(errorText)
}
let preparedStatement = SqlitePreparedStatement(statement: statement)
@@ -2297,6 +2306,7 @@ public final class SqliteValueBox: ValueBox {
self.clearStatements()
if self.isReadOnly {
postboxLogSync()
preconditionFailure()
}
@@ -2346,6 +2356,7 @@ public final class SqliteValueBox: ValueBox {
private func reencryptInPlace(database: Database, encryptionParameters: ValueBoxEncryptionParameters) -> Database {
if self.isReadOnly {
postboxLogSync()
preconditionFailure()
}