Skip to content
Open
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
14 changes: 11 additions & 3 deletions src/installer/commands/make_directory_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ impl MakeDirectoryCommand {
}

/// # Errors
/// Returns an error if the command execution fails.
/// Returns an error if the command execution fails, unless the path already exists
pub fn execute(&self, cleanup_file: &mut dyn Write) -> Result<()> {
fs::create_dir(&self.directory)?;
writeln!(cleanup_file, "{}", self.directory.display())?;
match fs::create_dir(&self.directory) {
Ok(()) => {
writeln!(cleanup_file, "{}", self.directory.display())?;
}
Err(e)
if e.kind() == std::io::ErrorKind::AlreadyExists
&& self.directory.is_dir() => {}
Err(e) => return Err(e.into()),
}

Ok(())
}

Expand Down