diff --git a/crates/puffin-client/src/registry_client.rs b/crates/puffin-client/src/registry_client.rs index 5410004f2..d2d3acba9 100644 --- a/crates/puffin-client/src/registry_client.rs +++ b/crates/puffin-client/src/registry_client.rs @@ -245,7 +245,8 @@ impl RegistryClient { .await? } FileLocation::Path(path) => { - let reader = fs_err::tokio::File::open(&path).await?; + let file = fs_err::tokio::File::open(&path).await?; + let reader = tokio::io::BufReader::new(file); read_metadata_async(&wheel.filename, built_dist.to_string(), reader).await? } }, @@ -258,7 +259,8 @@ impl RegistryClient { .await? } BuiltDist::Path(wheel) => { - let reader = fs_err::tokio::File::open(&wheel.path).await?; + let file = fs_err::tokio::File::open(&wheel.path).await?; + let reader = tokio::io::BufReader::new(file); read_metadata_async(&wheel.filename, built_dist.to_string(), reader).await? } }; diff --git a/crates/puffin-distribution/src/download.rs b/crates/puffin-distribution/src/download.rs index 1ac8f67a5..5ca29962e 100644 --- a/crates/puffin-distribution/src/download.rs +++ b/crates/puffin-distribution/src/download.rs @@ -1,14 +1,7 @@ use std::path::{Path, PathBuf}; -use anyhow::Result; -use zip::ZipArchive; - use distribution_filename::WheelFilename; use distribution_types::{CachedDist, Dist}; -use install_wheel_rs::read_dist_info; -use pypi_types::Metadata21; - -use crate::error::Error; /// A wheel that's been unzipped while downloading #[derive(Debug, Clone)] @@ -126,14 +119,3 @@ impl std::fmt::Display for LocalWheel { write!(f, "{}", self.remote()) } } - -impl BuiltWheel { - /// Read the [`Metadata21`] from a wheel. - pub fn read_dist_info(&self) -> Result { - let mut archive = ZipArchive::new(fs_err::File::open(&self.path)?)?; - let dist_info = read_dist_info(&self.filename, &mut archive).map_err(|err| { - Error::DistInfo(Box::new(self.filename.clone()), self.dist.to_string(), err) - })?; - Ok(Metadata21::parse(&dist_info)?) - } -} diff --git a/crates/puffin-distribution/src/error.rs b/crates/puffin-distribution/src/error.rs index f5e9a8a8a..f77e16e84 100644 --- a/crates/puffin-distribution/src/error.rs +++ b/crates/puffin-distribution/src/error.rs @@ -1,19 +1,9 @@ -use distribution_filename::WheelFilename; - #[derive(thiserror::Error, Debug)] -pub enum Error { +pub(crate) enum Error { #[error(transparent)] IO(#[from] std::io::Error), #[error(transparent)] PypiTypes(#[from] pypi_types::Error), #[error(transparent)] Zip(#[from] zip::result::ZipError), - #[error("Unable to read .dist-info directory in {0} from {1}")] - DistInfo( - Box, - String, - #[source] install_wheel_rs::Error, - ), - #[error("Unable to parse wheel filename for: {0}")] - FilenameParse(String, #[source] anyhow::Error), } diff --git a/crates/puffin-distribution/src/source/mod.rs b/crates/puffin-distribution/src/source/mod.rs index ae48c8d85..6a1e34d4d 100644 --- a/crates/puffin-distribution/src/source/mod.rs +++ b/crates/puffin-distribution/src/source/mod.rs @@ -1005,7 +1005,9 @@ fn read_wheel_metadata( filename: &WheelFilename, wheel: impl Into, ) -> Result { - let mut archive = ZipArchive::new(fs_err::File::open(wheel)?)?; + let file = fs_err::File::open(wheel)?; + let reader = std::io::BufReader::new(file); + let mut archive = ZipArchive::new(reader)?; let dist_info = read_dist_info(filename, &mut archive)?; Ok(Metadata21::parse(&dist_info)?) }