crypto: Use a transaction to create sqlite tables.
parent
dd0642cd59
commit
959e8450af
|
@ -26,6 +26,7 @@ use matrix_sdk_common_macros::async_trait;
|
|||
|
||||
use super::{
|
||||
caches::{DeviceStore, GroupSessionStore, SessionStore},
|
||||
pickle_key::EncryptedPickleKey,
|
||||
Changes, CryptoStore, InboundGroupSession, ReadOnlyAccount, Result, Session,
|
||||
};
|
||||
use crate::identities::{ReadOnlyDevice, UserIdentities};
|
||||
|
|
|
@ -46,6 +46,7 @@ pub(crate) mod sqlite;
|
|||
|
||||
use matrix_sdk_common::identifiers::DeviceIdBox;
|
||||
pub use memorystore::MemoryStore;
|
||||
use pickle_key::EncryptedPickleKey;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "sqlite_cryptostore")]
|
||||
pub use sqlite::SqliteStore;
|
||||
|
|
|
@ -167,7 +167,9 @@ impl SqliteStore {
|
|||
|
||||
async fn create_tables(&self) -> Result<()> {
|
||||
let mut connection = self.connection.lock().await;
|
||||
connection
|
||||
let mut transaction = connection.begin().await?;
|
||||
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
|
@ -183,7 +185,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
|
@ -202,7 +204,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS tracked_users (
|
||||
|
@ -220,7 +222,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS inbound_group_sessions (
|
||||
|
@ -241,7 +243,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS group_session_claimed_keys (
|
||||
|
@ -259,7 +261,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS group_session_chains (
|
||||
|
@ -276,7 +278,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS devices (
|
||||
|
@ -296,7 +298,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS algorithms (
|
||||
|
@ -313,7 +315,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS device_keys (
|
||||
|
@ -331,7 +333,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS device_signatures (
|
||||
|
@ -350,7 +352,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
|
@ -367,7 +369,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS users_trust_state (
|
||||
|
@ -382,7 +384,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS cross_signing_keys (
|
||||
|
@ -399,7 +401,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS user_keys (
|
||||
|
@ -416,7 +418,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS user_key_signatures (
|
||||
|
@ -435,7 +437,7 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
connection
|
||||
transaction
|
||||
.execute(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS key_value (
|
||||
|
@ -453,6 +455,8 @@ impl SqliteStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue