Skip to content

Commit

Permalink
🐛 prevent deleting versions dir when uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Sep 28, 2024
1 parent ea93aa8 commit dc2610e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ impl Version {

pub fn root_path(&self, config: &config::PactupConfig) -> Option<PathBuf> {
let path = self.installation_path(config);
let mut canon_path = path.canonicalize().ok()?;
canon_path.pop();
Some(canon_path)
path.canonicalize().ok().and_then(|canon_path| {
// If the path is a directory and it exists,also not the installations directory
if canon_path.is_dir() && canon_path.exists() && canon_path != config.installations_dir() {
Some(canon_path)
} else {
None
}
})
}

pub fn is_nightly(&self) -> bool {
Expand Down

0 comments on commit dc2610e

Please sign in to comment.