Skip to content

Commit

Permalink
fix: create snapshots directory if it doesn't exist (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos authored Jan 6, 2025
1 parent 4962f68 commit 1a7e04a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions staking/cli/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,10 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) {
)
.collect::<Vec<_>>();

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);
Expand Down

0 comments on commit 1a7e04a

Please sign in to comment.