diff --git a/src/utils/utils.rs b/src/utils/utils.rs index e4d7e9adb95..b6ac5c38c0c 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -10,10 +10,13 @@ use retry::{retry, OperationResult}; use sha2::Sha256; use url::Url; -use crate::currentprocess::{cwdsource::CurrentDirSource, varsource::VarSource}; use crate::errors::*; use crate::utils::notifications::Notification; use crate::utils::raw; +use crate::{ + currentprocess::{cwdsource::CurrentDirSource, varsource::VarSource}, + utils::raw::open_dir_following_links, +}; use crate::{home_process, process}; #[cfg(not(windows))] @@ -611,7 +614,9 @@ where } pub(crate) fn delete_dir_contents(dir_path: &Path) { - match remove_dir_all::remove_dir_contents(dir_path) { + use remove_dir_all::RemoveDir; + + match open_dir_following_links(dir_path).and_then(|mut p| p.remove_dir_contents(None)) { Err(e) if e.kind() != io::ErrorKind::NotFound => { panic!("Unable to clean up {}: {:?}", dir_path.display(), e); }