Return computed hashes from metadata requests (#2951)

## Summary

This PR modifies the distribution database to return both the
`Metadata23` and the computed hashes when clients request metadata.

No behavior changes, but this will be necessary to power
`--generate-hashes`.
This commit is contained in:
Charlie Marsh 2024-04-10 15:31:41 -04:00 committed by GitHub
parent c18551fd3c
commit 8513d603b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 100 additions and 60 deletions

View file

@ -4,6 +4,7 @@ pub use download::LocalWheel;
pub use error::Error;
pub use git::{is_same_reference, to_precise};
pub use index::{BuiltWheelIndex, RegistryWheelIndex};
use pypi_types::{HashDigest, Metadata23};
pub use reporter::Reporter;
pub use source::SourceDistributionBuilder;
@ -16,3 +17,21 @@ mod index;
mod locks;
mod reporter;
mod source;
/// The metadata associated with an archive.
#[derive(Debug, Clone)]
pub struct ArchiveMetadata {
/// The [`Metadata23`] for the underlying distribution.
pub metadata: Metadata23,
/// The hashes of the source or built archive.
pub hashes: Vec<HashDigest>,
}
impl From<Metadata23> for ArchiveMetadata {
fn from(metadata: Metadata23) -> Self {
Self {
metadata,
hashes: vec![],
}
}
}