install: Don't display success message when the dir was not created

Also don't run chmod when we just failed to create the directory.

Behaviour before this patch:

    $ ./target/release/install -v -d dir1/dir2
    install: dir1/dir2: Permission denied (os error 13)
    install: dir1/dir2: chmod failed with error No such file or directory (os error 2)
    install: created directory 'dir1/dir2'
This commit is contained in:
Juliana Rodrigueiro 2021-04-02 19:13:56 +01:00
parent 349c4f7af6
commit 2a02f01fc2

View file

@ -364,15 +364,17 @@ fn directory(paths: Vec<String>, b: Behavior) -> i32 {
if let Err(e) = fs::create_dir(directory) {
show_info!("{}: {}", path.display(), e.to_string());
all_successful = false;
continue;
}
if b.verbose {
show_info!("creating directory '{}'", path.display());
}
}
if mode::chmod(&path, b.mode()).is_err() {
all_successful = false;
}
if b.verbose {
show_info!("creating directory '{}'", path.display());
continue;
}
}
if all_successful {