diff options
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/project.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/types/project.rs b/src/types/project.rs index 11789ac..7262ccf 100644 --- a/src/types/project.rs +++ b/src/types/project.rs @@ -62,7 +62,14 @@ impl Project { self, path: Option<PathBuf>, ) -> Result<PathBuf, Error> { + use tokio::fs; + let path = if let Some(p) = path { + let parent = p.parent(); + if parent.is_some_and(|parent| !parent.exists()) { + fs::create_dir_all(parent.unwrap()).await?; + } + p } else { rfd::AsyncFileDialog::new() @@ -77,7 +84,7 @@ impl Project { }; let contents = serde_json::to_string(&self)?; - tokio::fs::write(&path, contents).await?; + fs::write(&path, contents).await?; Ok(path) } |
