From 312f3d124f2fca259bdc9fd070af79008b6aeda0 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sun, 12 May 2024 14:53:16 +0200 Subject: [PATCH] fixup some sqlcipher issues --- Cargo.toml | 3 +-- src/context.rs | 7 +++++-- src/sql.rs | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b060bb6291..532899def9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -174,10 +174,9 @@ chrono = { version = "0.4.38", default-features=false, features = ["alloc", "clo [features] default = ["vendored", "sqlcipher"] internals = [] -sqlcipher = ["rusqlite/sqlcipher"] +sqlcipher = ["rusqlite/bundled-sqlcipher-vendored-openssl"] vendored = [ "async-native-tls/vendored", - "rusqlite/bundled-sqlcipher-vendored-openssl", "reqwest/native-tls-vendored" ] diff --git a/src/context.rs b/src/context.rs index 806c2c622f..71c573661f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1410,10 +1410,13 @@ mod tests { let tmp = tempfile::tempdir()?; let dbfile = tmp.path().join("db.sqlite"); tokio::fs::write(&dbfile, b"123").await?; - let res = Context::new(&dbfile, 1, Events::new(), StockStrings::new()).await?; + let res = Context::new(&dbfile, 1, Events::new(), StockStrings::new()).await; // Broken database is indistinguishable from encrypted one. - assert_eq!(res.is_open().await, false); + #[cfg(feature = "sqlcipher")] + assert_eq!(res?.is_open().await, false); + #[cfg(not(feature = "sqlcipher"))] + assert!(res.is_err()); Ok(()) } diff --git a/src/sql.rs b/src/sql.rs index 7f913cb5a0..52b62c76b8 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -162,6 +162,8 @@ impl Sql { .context("failed to vacuum the database")?; conn.set_db_config(DbConfig::SQLITE_DBCONFIG_RESET_DATABASE, false) .context("failed to unset SQLITE_DBCONFIG_RESET_DATABASE")?; + + #[cfg(feature = "sqlcipher")] let res = conn .query_row("SELECT sqlcipher_export('main', 'backup')", [], |_row| { Ok(()) @@ -169,6 +171,7 @@ impl Sql { .context("failed to import from attached backup database"); conn.execute("DETACH DATABASE backup", []) .context("failed to detach backup database")?; + #[cfg(feature = "sqlcipher")] res?; Ok(()) })