From 8668381b8f716fc8d9b59da61bfd7e2475c69361 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 18 Jul 2024 13:39:05 -0400 Subject: [PATCH] only run sqlite cipher debugging if enc key is provided --- xmtp_mls/src/storage/encrypted_store/mod.rs | 23 ++++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/xmtp_mls/src/storage/encrypted_store/mod.rs b/xmtp_mls/src/storage/encrypted_store/mod.rs index 1419c08f6..fa4ba553c 100644 --- a/xmtp_mls/src/storage/encrypted_store/mod.rs +++ b/xmtp_mls/src/storage/encrypted_store/mod.rs @@ -152,18 +152,21 @@ impl EncryptedMessageStore { conn.run_pending_migrations(MIGRATIONS) .map_err(|e| StorageError::DbInit(e.to_string()))?; - let cipher_version = sql_query("PRAGMA cipher_version").load::(conn)?; - let cipher_provider_version = - sql_query("PRAGMA cipher_provider_version").load::(conn)?; let sqlite_version = sql_query("SELECT sqlite_version() AS version").load::(conn)?; - log::info!( - "Sql cipher version={}, cipher provider version={}, sqlite_version={}", - cipher_version[0].cipher_version, - cipher_provider_version[0].cipher_provider_version, - sqlite_version[0].version, - ); - conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;")?; + log::info!("sqlite_version={}", sqlite_version[0].version); + + if self.enc_key.is_some() { + let cipher_version = sql_query("PRAGMA cipher_version").load::(conn)?; + let cipher_provider_version = + sql_query("PRAGMA cipher_provider_version").load::(conn)?; + log::info!( + "Sqlite cipher_version={}, cipher_provider_version={}", + cipher_version[0].cipher_version, + cipher_provider_version[0].cipher_provider_version, + ); + conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;")?; + } log::info!("Migrations successful"); Ok(())