From 1a7e04ad19e04e1d203522601c3158191f8d964c Mon Sep 17 00:00:00 2001 From: guibescos <59208140+guibescos@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:12:05 +0100 Subject: [PATCH] fix: create snapshots directory if it doesn't exist (#550) --- staking/cli/src/instructions.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index e2a4c822..34a4c51e 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1098,6 +1098,10 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { ) .collect::>(); + if !std::path::Path::new("snapshots").exists() { + std::fs::create_dir_all("snapshots").unwrap(); + } + let timestamp = chrono::Utc::now().format("%Y-%m-%d_%H:%M:%S").to_string(); let file = File::create(format!("snapshots/snapshot-{}.csv", timestamp)).unwrap(); let mut writer = BufWriter::new(file);