From f3400a0aa53de2c907470d5c190885e3310617a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Wed, 12 Feb 2025 17:29:06 +0100 Subject: [PATCH] Add helper to extract a list of sqlite files with journal files wal/shm (#5452) Co-authored-by: Andrej Mihajlov --- sdk/rust/nym-sdk/src/mixnet/paths.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sdk/rust/nym-sdk/src/mixnet/paths.rs b/sdk/rust/nym-sdk/src/mixnet/paths.rs index 4c7dcee6cd..5f8d60a7de 100644 --- a/sdk/rust/nym-sdk/src/mixnet/paths.rs +++ b/sdk/rust/nym-sdk/src/mixnet/paths.rs @@ -134,6 +134,18 @@ impl StoragePaths { Ok(non_wasm_helpers::setup_fs_gateways_storage(&self.gateway_registrations).await?) } + pub fn credential_database_paths(&self) -> Vec { + Self::with_sqlite_journal_paths(&self.credential_database_path) + } + + pub fn reply_surb_database_paths(&self) -> Vec { + Self::with_sqlite_journal_paths(&self.reply_surb_database_path) + } + + pub fn gateway_registrations_paths(&self) -> Vec { + Self::with_sqlite_journal_paths(&self.gateway_registrations) + } + fn client_keys_paths(&self) -> ClientKeysPaths { ClientKeysPaths { private_identity_key_file: self.private_identity.clone(), @@ -143,6 +155,19 @@ impl StoragePaths { ack_key_file: self.ack_key.clone(), } } + + /// Returns a list of paths that include the sqlite database and journal files (wal, shm) + fn with_sqlite_journal_paths>(db_file: P) -> Vec { + ["-shm", "-wal"] + .iter() + .map(|ext_suffix| { + let mut new_ext = db_file.as_ref().extension().unwrap_or_default().to_owned(); + new_ext.push(ext_suffix); + db_file.as_ref().with_extension(new_ext) + }) + .chain([db_file.as_ref().to_path_buf()]) + .collect() + } } impl From for CommonClientPaths {