tools: create_dir: pass EEXIST to the caller

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-12-18 13:37:10 +01:00
parent 3c284b131d
commit 867a530724

View File

@ -217,7 +217,7 @@ impl CreateOptions {
/// Creates directory at the provided path with specified ownership.
///
/// Simply returns if the directory already exists.
/// Errors if the directory already exists.
pub fn create_dir<P: AsRef<Path>>(path: P, options: CreateOptions) -> Result<(), nix::Error> {
// clippy bug?: from_bits_truncate is actually a const fn...
#[allow(clippy::or_fun_call)]
@ -229,9 +229,6 @@ pub fn create_dir<P: AsRef<Path>>(path: P, options: CreateOptions) -> Result<(),
match nix::unistd::mkdir(path, mode) {
Ok(()) => {}
Err(nix::Error::Sys(Errno::EEXIST)) => {
return Ok(());
}
err => return err,
}