feat: delete/uninstall packages #2181
Open
+74
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2147
Details about the implementation
To add the
delete
command, I followed the same pattern that existed in thesrc/args.rs
,src/main.rs
andsrc/package/*
directories.I tried to follow the existing code style, and kept refactorings to a minimum - I created two helper methods -
find_dep_in_package
anddeployed_directory
. If there are any naming issues or you would like the code to be structured differently, feel free to say!Follow up / Questions
Some code is still not deleted
As things are, this will not delete the package code that is present in
Xdg::local()
directory, as I don't understand why thestate_dir()
of a dependency is using an hash to identify the package (format!("{:x}", XxHash3_128::oneshot(self.remote().as_bytes()))
) instead of just using the package name.I'm assuming it is desired to also remove the content of this
state_dir()
, but I'llawait
for the answer 🕵️Can the field
Dependency.use_
be used the dependency ID?The function
Package::add(..)
was detecting if a package existing with the following code:However, given that the objective is to see if a package already exists in
package.toml
and each package keeps theuse
value there, I'm under the impression that this can be simplified to usinguse_
.If this
use
field is internal and should not be used, should there be a way of giving an ID to a package, or should we keep using theparent
andchild
names?