mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Prune unused source distributions from the cache (#7112)
## Summary This has bothered me for a while and should be fairly impactful for users. It requires a weird implementation, since the distribution-building crate depends on the cache, and so the prune operation can't live in the cache, since it needs to access internals of the distribution-building crate. Closes https://github.com/astral-sh/uv/issues/7096.
This commit is contained in:
parent
1422e18674
commit
93fe3e83be
10 changed files with 213 additions and 10 deletions
|
@ -18,7 +18,7 @@ use uv_normalize::PackageName;
|
|||
pub use crate::by_timestamp::CachedByTimestamp;
|
||||
#[cfg(feature = "clap")]
|
||||
pub use crate::cli::CacheArgs;
|
||||
use crate::removal::{rm_rf, Removal};
|
||||
pub use crate::removal::{rm_rf, Removal};
|
||||
pub use crate::timestamp::Timestamp;
|
||||
pub use crate::wheel::WheelCache;
|
||||
use crate::wheel::WheelCacheKind;
|
||||
|
@ -458,9 +458,7 @@ impl Cache {
|
|||
}
|
||||
}
|
||||
|
||||
// Third, remove any unused archives (by searching for archives that are not symlinked).
|
||||
// TODO(charlie): Remove any unused source distributions. This requires introspecting the
|
||||
// cache contents, e.g., reading and deserializing the manifests.
|
||||
// Fourth, remove any unused archives (by searching for archives that are not symlinked).
|
||||
let mut references = FxHashSet::default();
|
||||
|
||||
for bucket in CacheBucket::iter() {
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::path::Path;
|
|||
|
||||
/// Remove a file or directory and all its contents, returning a [`Removal`] with
|
||||
/// the number of files and directories removed, along with a total byte count.
|
||||
pub(crate) fn rm_rf(path: impl AsRef<Path>) -> io::Result<Removal> {
|
||||
pub fn rm_rf(path: impl AsRef<Path>) -> io::Result<Removal> {
|
||||
let mut removal = Removal::default();
|
||||
removal.rm_rf(path.as_ref())?;
|
||||
Ok(removal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue