Avoid returning zipped wheels from registry and URL indexes (#558)

## Summary

This is hard to reproduce, but if you run a long installation process
that errors part-way through, you can end up with zipped wheels in the
`Wheels` cache, which is intended to contain only unzipped wheels. This
PR avoids returning those entries from the registry, which will then
lead to errors downstream when we treat them as directories.
This commit is contained in:
Charlie Marsh 2023-12-05 03:53:45 -05:00 committed by GitHub
parent 2d1e19e474
commit f99e3560e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -103,7 +103,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
}
}
/// In parallel, either fetch the wheel or fetch and built source distributions.
/// In parallel, either fetch each wheel or build each source distribution.
pub async fn get_wheels(
&self,
dists: Vec<Dist>,
@ -191,7 +191,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
small_size.map_or("unknown size".to_string(), |size| size.to_string());
debug!("Fetching disk-based wheel from registry: {dist} ({size})");
// Download the wheel to a temporary file.
// Download the wheel into the cache.
fs::create_dir_all(&cache_entry.dir).await?;
let mut writer = fs::File::create(cache_entry.path()).await?;
tokio::io::copy(&mut reader.compat(), &mut writer).await?;