Skip to content

Commit

Permalink
[rust] Fix logic to create empty parent path
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Sep 30, 2023
1 parent 0c925bb commit e87ad2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rust/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ impl BrowserPath {
}

pub fn create_empty_parent_path_if_not_exists(path: &Path) -> Result<(), Box<dyn Error>> {
create_parent_path_if_not_exists(path)?;
fs::remove_dir_all(path).and_then(|_| fs::create_dir(path))?;
if let Some(p) = path.parent() {
create_path_if_not_exists(p)?;
fs::remove_dir_all(p).and_then(|_| fs::create_dir(p))?;
}
Ok(())
}

Expand Down

0 comments on commit e87ad2b

Please sign in to comment.