Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create non-existent dir #336

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cw-orch-daemon/src/json_file.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use crate::DaemonError;
use serde_json::{from_reader, json, Value};
use std::fs::{File, OpenOptions};
use std::{
fs::{File, OpenOptions},
path::PathBuf,
str::FromStr,
};

pub fn write(filename: &String, chain_id: &String, network_id: &String, deploy_id: &String) {
// open file pointer set read/write permissions to true
// create it if it does not exists
// dont truncate it
// Create the directory if they do not exist
let file_buf = PathBuf::from_str(filename).unwrap();
if let Some(parent) = file_buf.parent() {
let _ = std::fs::create_dir_all(parent);
}

let file = OpenOptions::new()
.create(true)
Expand Down
Loading