Use globwalk for cache-keys matching (#7337)

## Summary

This should be more efficient as we can do a single traversal.

Closes https://github.com/astral-sh/uv/issues/7321.
This commit is contained in:
Charlie Marsh 2024-09-12 15:06:05 -04:00 committed by GitHub
parent d52af0ccdd
commit 65d53a7474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 74 additions and 77 deletions

View file

@ -46,6 +46,8 @@ pub enum Error {
CacheEncode(#[from] rmp_serde::encode::Error),
#[error("Failed to walk the distribution cache")]
CacheWalk(#[source] walkdir::Error),
#[error(transparent)]
CacheInfo(#[from] uv_cache_info::CacheInfoError),
// Build error
#[error(transparent)]

View file

@ -132,8 +132,7 @@ impl<'a> BuiltWheelIndex<'a> {
};
// If the distribution is stale, omit it from the index.
let cache_info =
CacheInfo::from_directory(&source_dist.install_path).map_err(Error::CacheRead)?;
let cache_info = CacheInfo::from_directory(&source_dist.install_path)?;
if cache_info != *pointer.cache_info() {
return Ok(None);

View file

@ -1112,8 +1112,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
}
// Determine the last-modified time of the source distribution.
let cache_info =
CacheInfo::from_directory(&resource.install_path).map_err(Error::CacheRead)?;
let cache_info = CacheInfo::from_directory(&resource.install_path)?;
// Read the existing metadata from the cache.
let entry = cache_shard.entry(LOCAL_REVISION);