Backtrack on distributions with invalid metadata (#2834)

## Summary

Closes https://github.com/astral-sh/uv/issues/2821.
This commit is contained in:
Charlie Marsh 2024-04-05 18:00:48 -04:00 committed by GitHub
parent f0b0e1943c
commit 00934044aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 229 additions and 73 deletions

View file

@ -132,7 +132,7 @@ pub enum ErrorKind {
/// Dist-info error
#[error(transparent)]
InstallWheel(#[from] install_wheel_rs::Error),
DistInfo(#[from] install_wheel_rs::Error),
#[error("{0} isn't available locally, but making network requests to registries was banned.")]
NoIndex(String),

View file

@ -632,7 +632,7 @@ async fn read_metadata_async_seek(
.enumerate()
.filter_map(|(index, entry)| Some((index, entry.filename().as_str().ok()?))),
)
.map_err(ErrorKind::InstallWheel)?;
.map_err(ErrorKind::DistInfo)?;
// Read the contents of the `METADATA` file.
let mut contents = Vec::new();

View file

@ -75,7 +75,7 @@ pub(crate) async fn wheel_metadata_from_remote_zip(
.enumerate()
.filter_map(|(idx, e)| Some(((idx, e), e.filename().as_str().ok()?))),
)
.map_err(ErrorKind::InstallWheel)?;
.map_err(ErrorKind::DistInfo)?;
let offset = metadata_entry.header_offset();
let size = metadata_entry.compressed_size()