Stream zip archive when fetching non-range-request metadata (#1792)

## Summary

If a registry doesn't support range requests, then today, we download
the entire wheel to disk and then read the metadata from the downloaded
archive. This PR instead modifies the registry client to stream the
zipfile and stop as soon as it's seen the metadata, which should be more
efficient.

Closes https://github.com/astral-sh/uv/issues/1596.

## Test Plan

Made this the _only_ path for downloading metadata; verified that the
test suite passed.
This commit is contained in:
Charlie Marsh 2024-02-20 22:12:21 -05:00 committed by GitHub
parent 31752bf4be
commit 5d53040465
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 102 additions and 32 deletions

View file

@ -68,6 +68,10 @@ pub enum ErrorKind {
#[error("Couldn't parse metadata of {0} from {1}")]
MetadataParseError(WheelFilename, String, #[source] Box<pypi_types::Error>),
/// The metadata file was not found in the wheel.
#[error("Metadata file `{0}` was not found in {1}")]
MetadataNotFound(WheelFilename, String),
/// The metadata file was not found in the registry.
#[error("File `{0}` was not found in the registry at {1}.")]
FileNotFound(String, #[source] reqwest::Error),