1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

rm: Fail when symlink_metadata() fails

This commit is contained in:
Shinichiro Hamaji 2017-04-04 00:10:45 +09:00
parent 4f6841df32
commit bb1d8956eb

View file

@ -129,7 +129,15 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
let filename = &filename[..];
let file = Path::new(filename);
if file.exists() {
if file.symlink_metadata().unwrap().is_dir() {
let is_dir = match file.symlink_metadata() {
Ok(metadata) => metadata.is_dir(),
Err(e) => {
had_err = true;
show_error!("could not read metadata of '{}': {}", filename, e);
continue;
}
};
if is_dir {
if recursive && (filename != "/" || !preserve_root) {
if interactive != InteractiveMode::InteractiveAlways {
if let Err(e) = fs::remove_dir_all(file) {