Skip to content

Commit

Permalink
fix(utils): resolve input path in delete_dir_contents() if it's a link
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Apr 2, 2024
1 parent b4f8c1c commit b553a5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b553a5f

Please sign in to comment.