Skip to content

Commit

Permalink
Use distribution hash over registry hash (#7060)
Browse files Browse the repository at this point in the history
## Summary

We need to prioritize hashes for the distribution over hashes for the
related packages.

I think this needs to be redone entirely though. I can see other issues
with the current approach.

Closes #7059.
  • Loading branch information
charliermarsh committed Sep 5, 2024
1 parent 595f590 commit 1f7a9a7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/uv-resolver/src/resolution/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,18 @@ impl ResolutionGraph {
}
}

// 2. Look for hashes from the registry, which are served at the package level.
// 2. Look for hashes for the distribution (i.e., the specific wheel or source distribution).
if let Some(metadata_response) = index.distributions().get(version_id) {
if let MetadataResponse::Found(ref archive) = *metadata_response {
let mut digests = archive.hashes.clone();
digests.sort_unstable();
if !digests.is_empty() {
return digests;
}
}
}

// 3. Look for hashes from the registry, which are served at the package level.
if let Some(versions_response) = index.packages().get(name) {
if let VersionsResponse::Found(ref version_maps) = *versions_response {
if let Some(digests) = version_maps
Expand All @@ -530,17 +541,6 @@ impl ResolutionGraph {
}
}

// 3. Look for hashes for the distribution (i.e., the specific wheel or source distribution).
if let Some(metadata_response) = index.distributions().get(version_id) {
if let MetadataResponse::Found(ref archive) = *metadata_response {
let mut digests = archive.hashes.clone();
digests.sort_unstable();
if !digests.is_empty() {
return digests;
}
}
}

vec![]
}

Expand Down

0 comments on commit 1f7a9a7

Please sign in to comment.