mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Centralize up-to-date checking for path installations (#2168)
## Summary Internal-only refactor to consolidate multiple codepaths we have for checking whether a cached or installed entry is up-to-date with a local requirement.
This commit is contained in:
parent
ffb69e3f48
commit
6f94dc3c77
8 changed files with 98 additions and 104 deletions
|
@ -13,9 +13,9 @@ use distribution_types::{
|
|||
};
|
||||
use platform_tags::Tags;
|
||||
use pypi_types::Metadata21;
|
||||
use uv_cache::{Cache, CacheBucket, Timestamp, WheelCache};
|
||||
use uv_cache::{ArchiveTarget, ArchiveTimestamp, Cache, CacheBucket, WheelCache};
|
||||
use uv_client::{CacheControl, CachedClientError, Connectivity, RegistryClient};
|
||||
use uv_fs::metadata_if_exists;
|
||||
|
||||
use uv_git::GitSource;
|
||||
use uv_traits::{BuildContext, NoBinary, NoBuild};
|
||||
|
||||
|
@ -123,19 +123,17 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
// return it.
|
||||
match cache_entry.path().canonicalize() {
|
||||
Ok(archive) => {
|
||||
if let (Some(cache_metadata), Some(path_metadata)) = (
|
||||
metadata_if_exists(&archive).map_err(Error::CacheRead)?,
|
||||
metadata_if_exists(path).map_err(Error::CacheRead)?,
|
||||
) {
|
||||
let cache_modified = Timestamp::from_metadata(&cache_metadata);
|
||||
let path_modified = Timestamp::from_metadata(&path_metadata);
|
||||
if cache_modified >= path_modified {
|
||||
return Ok(LocalWheel::Unzipped(UnzippedWheel {
|
||||
dist: dist.clone(),
|
||||
archive,
|
||||
filename: wheel.filename.clone(),
|
||||
}));
|
||||
}
|
||||
if ArchiveTimestamp::up_to_date_with(
|
||||
path,
|
||||
ArchiveTarget::Cache(&archive),
|
||||
)
|
||||
.map_err(Error::CacheRead)?
|
||||
{
|
||||
return Ok(LocalWheel::Unzipped(UnzippedWheel {
|
||||
dist: dist.clone(),
|
||||
archive,
|
||||
filename: wheel.filename.clone(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
|
||||
|
@ -290,19 +288,17 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
// return it.
|
||||
match cache_entry.path().canonicalize() {
|
||||
Ok(archive) => {
|
||||
if let (Some(cache_metadata), Some(path_metadata)) = (
|
||||
metadata_if_exists(&archive).map_err(Error::CacheRead)?,
|
||||
metadata_if_exists(&wheel.path).map_err(Error::CacheRead)?,
|
||||
) {
|
||||
let cache_modified = Timestamp::from_metadata(&cache_metadata);
|
||||
let path_modified = Timestamp::from_metadata(&path_metadata);
|
||||
if cache_modified >= path_modified {
|
||||
return Ok(LocalWheel::Unzipped(UnzippedWheel {
|
||||
dist: dist.clone(),
|
||||
archive,
|
||||
filename: wheel.filename.clone(),
|
||||
}));
|
||||
}
|
||||
if ArchiveTimestamp::up_to_date_with(
|
||||
&wheel.path,
|
||||
ArchiveTarget::Cache(&archive),
|
||||
)
|
||||
.map_err(Error::CacheRead)?
|
||||
{
|
||||
return Ok(LocalWheel::Unzipped(UnzippedWheel {
|
||||
dist: dist.clone(),
|
||||
archive,
|
||||
filename: wheel.filename.clone(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue