Skip to content

Commit

Permalink
fix: rm not working
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Jan 25, 2023
1 parent 68442ad commit 46144fd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/vpm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,21 @@ mod vpm_manifest {
}

pub(crate) fn remove_packages(&mut self, names: &[&str]) {
for name in names {
self.locked.remove(*name);
self.dependencies.remove(*name);
for name in names.into_iter().copied() {
self.locked.remove(name);
self.json
.get_mut("locked")
.unwrap()
.as_object_mut()
.unwrap()
.remove(name);
self.dependencies.remove(name);
self.json
.get_mut("dependencies")
.unwrap()
.as_object_mut()
.unwrap()
.remove(name);
}
self.changed = true;
}
Expand Down Expand Up @@ -911,6 +923,14 @@ impl UnityProject {
// there's no conflicts. So do remove

self.manifest.remove_packages(names);
try_join_all(names.into_iter().map(|name| {
remove_dir_all(self.packages_dir.join(name)).map(|x| match x {
Ok(()) => Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => Ok(()),
Err(e) => Err(e),
})
}))
.await?;

Ok(())
}
Expand Down

0 comments on commit 46144fd

Please sign in to comment.