diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index a5cd47b933..ad81610a91 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1007,7 +1007,7 @@ fn update(cfg: &mut Cfg, m: &ArgMatches) -> Result { } else { common::update_all_channels(cfg, self_update, m.get_flag("force"))?; info!("cleaning up downloads & tmp directories"); - utils::delete_dir_contents(&cfg.download_dir); + utils::delete_dir_contents_following_links(&cfg.download_dir); cfg.temp_cfg.clean(); } diff --git a/src/dist/temp.rs b/src/dist/temp.rs index 8c8a9b3b99..e5eb54b1e5 100644 --- a/src/dist/temp.rs +++ b/src/dist/temp.rs @@ -158,7 +158,7 @@ impl Cfg { } pub(crate) fn clean(&self) { - utils::delete_dir_contents(&self.root_directory); + utils::delete_dir_contents_following_links(&self.root_directory); } } diff --git a/src/utils/utils.rs b/src/utils/utils.rs index 44764255fd..e2ad7c0ba8 100644 --- a/src/utils/utils.rs +++ b/src/utils/utils.rs @@ -610,7 +610,7 @@ where }) } -pub(crate) fn delete_dir_contents(dir_path: &Path) { +pub(crate) fn delete_dir_contents_following_links(dir_path: &Path) { use remove_dir_all::RemoveDir; match raw::open_dir_following_links(dir_path).and_then(|mut p| p.remove_dir_contents(None)) {