From: Daniela Brozzoni Date: Tue, 30 Aug 2022 15:22:12 +0000 (+0200) Subject: `open_database` avoids creating a wallet dir if... X-Git-Tag: v0.6.0~2^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/struct.CommandStringError.html?a=commitdiff_plain;h=bff2d375a1dc811b96e0ce47b21ab8ebb17f1d23;p=bdk-cli `open_database` avoids creating a wallet dir if... ...not necessary This is useful for the wasm integration, where we want to call the `open_database` function directly, without wanting it to create any directories. Note that when using bdk-cli normally, it won't create a db directory if it's useless, but it will still create a base directory (even if empty). This is suboptimal, but fixing it would require a quite big refactor to the code. --- diff --git a/src/utils.rs b/src/utils.rs index 566db9f..0ebd9a5 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -164,6 +164,11 @@ pub(crate) fn prepare_home_dir(home_path: Option) -> Result Result { let mut dir = home_path.to_owned(); @@ -178,6 +183,7 @@ fn prepare_wallet_dir(wallet_name: &str, home_path: &Path) -> Result Result { let mut db_dir = prepare_wallet_dir(wallet_name, home_path)?; @@ -248,12 +254,14 @@ pub(crate) fn prepare_electrum_datadir(home_path: &Path) -> Result Result { let wallet_name = wallet_opts.wallet.as_ref().expect("wallet name"); + #[cfg(any(feature = "key-value-db", feature = "sqlite-db",))] let database_path = prepare_wallet_db_dir(wallet_name, home_path)?; #[cfg(feature = "key-value-db")]