diff --git a/Cargo.lock b/Cargo.lock index c5237d4b5..162410db6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4829,7 +4829,6 @@ dependencies = [ "uv-cache-info", "uv-cache-key", "uv-dirs", - "uv-distribution-filename", "uv-distribution-types", "uv-fs", "uv-normalize", diff --git a/crates/uv-cache/Cargo.toml b/crates/uv-cache/Cargo.toml index dc304da98..a3a9ab76b 100644 --- a/crates/uv-cache/Cargo.toml +++ b/crates/uv-cache/Cargo.toml @@ -20,7 +20,6 @@ workspace = true uv-cache-info = { workspace = true } uv-cache-key = { workspace = true } uv-dirs = { workspace = true } -uv-distribution-filename = { workspace = true } uv-distribution-types = { workspace = true } uv-fs = { workspace = true, features = ["tokio"] } uv-normalize = { workspace = true } diff --git a/crates/uv-cache/src/lib.rs b/crates/uv-cache/src/lib.rs index 8b68d4ff3..bdbd6f328 100644 --- a/crates/uv-cache/src/lib.rs +++ b/crates/uv-cache/src/lib.rs @@ -11,7 +11,6 @@ use tracing::debug; pub use archive::ArchiveId; use uv_cache_info::Timestamp; -use uv_distribution_filename::WheelFilename; use uv_fs::{cachedir, directories, LockedFile}; use uv_normalize::PackageName; use uv_pypi_types::ResolutionMetadata; @@ -534,47 +533,28 @@ impl Cache { fn find_archive_references(&self) -> Result, io::Error> { let mut references = FxHashSet::default(); for bucket in CacheBucket::iter() { + // As an optimization, skip the archive bucket itself. + if matches!(bucket, CacheBucket::Archive) { + continue; + } + let bucket_path = self.bucket(bucket); if bucket_path.is_dir() { for entry in walkdir::WalkDir::new(bucket_path) { let entry = entry?; - // Ignore any `.lock` files. - if entry - .path() - .extension() - .is_some_and(|ext| ext.eq_ignore_ascii_case("lock")) - { + // As an optimization, ignore any `.lock`, `.whl`, `.msgpack`, `.rev`, or + // `.http` files. + if entry.path().extension().is_some_and(|ext| { + ext.eq_ignore_ascii_case("lock") + || ext.eq_ignore_ascii_case("whl") + || ext.eq_ignore_ascii_case("http") + || ext.eq_ignore_ascii_case("rev") + || ext.eq_ignore_ascii_case("msgpack") + }) { continue; } - let Some(filename) = entry - .path() - .file_name() - .and_then(|file_name| file_name.to_str()) - else { - continue; - }; - - if bucket == CacheBucket::Wheels { - // In the `wheels` bucket, we often use a hash of the filename as the - // directory name, so we can't rely on the stem. - // - // Instead, we skip if it contains an extension (e.g., `.whl`, `.http`, - // `.rev`, and `.msgpack` files). - if filename - .rsplit_once('-') // strip version/tags, might contain a dot ('.') - .is_none_or(|(_, suffix)| suffix.contains('.')) - { - continue; - } - } else { - // For other buckets only include entries that match the wheel stem pattern (e.g., `typing-extensions-4.8.0-py3-none-any`). - if WheelFilename::from_stem(filename).is_err() { - continue; - } - } - if let Ok(target) = self.resolve_link(entry.path()) { references.insert(target); }