Skip to content

Commit

Permalink
[rust] Replace function for creating parent path if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Nov 13, 2023
1 parent 9e33a0b commit de22f34
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions rust/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ impl BrowserPath {
}
}

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

pub fn create_parent_path_if_not_exists(path: &Path) -> Result<(), Error> {
if let Some(p) = path.parent() {
create_path_if_not_exists(p)?;
Expand Down Expand Up @@ -185,7 +177,7 @@ pub fn uncompress_sfx(compressed_file: &str, target: &Path, log: &Logger) -> Res
"Moving extracted files and folders from {} to {}",
core_str, target_str
));
create_empty_parent_path_if_not_exists(target)?;
create_parent_path_if_not_exists(target)?;
fs::rename(&core_str, &target_str)?;

Ok(())
Expand Down Expand Up @@ -291,7 +283,7 @@ pub fn uncompress_deb(
"Moving extracted files and folders from {} to {}",
opt_edge_str, target_str
));
create_empty_parent_path_if_not_exists(target)?;
create_parent_path_if_not_exists(target)?;
fs::rename(&opt_edge_str, &target_str)?;

Ok(())
Expand Down

0 comments on commit de22f34

Please sign in to comment.