fix(vendor): dont remove non-cached source #15260
Merged
+92
−6
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.
What does this PR try to resolve?
Fixes #15244
With this fix,
cargo vendor
will not delete original sources,if you want to vendor things from one directory sources to the other
Background
cargo-vendor has a workaround that to mitigate #5956:
it removes all cached sources in order to trigger a re-unpack.
It was meant for dealing with registry sources only,
but accidentally applied to directory source kind.
While directory source kind was invented for vendoring,
and vendoring from one vendored directory to the other seems unusual,
Cargo IMO should not delete any real sources.
It does not mean that registry sources are okay to delete,
In long term, we should explore a way that unpacks
.crate
filesdirectly, without any removal. See
#12509 (comment)
How should we test and review this PR?
The added test should suffice.
Also, although this is for fixing #15244,
cargo vendor
still doesn't support vendor from and to the same location.Unless we figure out an
rsync
-like solutin to update vendor sources,it is not going to support in short term.
(And I also doubt the real world use case of it)
Additional information