mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-15 12:59:02 +00:00
Skip copying to empty entries in seekable zip (#5571)
## Summary We cannot do this when streaming, since we may not have the metadata for the entry. Closes https://github.com/astral-sh/uv/issues/5565.
This commit is contained in:
parent
f70501a22e
commit
cf94a10054
1 changed files with 8 additions and 6 deletions
|
@ -48,12 +48,14 @@ pub fn unzip<R: Send + std::io::Read + std::io::Seek + HasLength>(
|
||||||
// Copy the file contents.
|
// Copy the file contents.
|
||||||
let outfile = fs_err::File::create(&path)?;
|
let outfile = fs_err::File::create(&path)?;
|
||||||
let size = file.size();
|
let size = file.size();
|
||||||
let mut writer = if let Ok(size) = usize::try_from(size) {
|
if size > 0 {
|
||||||
std::io::BufWriter::with_capacity(std::cmp::min(size, 1024 * 1024), outfile)
|
let mut writer = if let Ok(size) = usize::try_from(size) {
|
||||||
} else {
|
std::io::BufWriter::with_capacity(std::cmp::min(size, 1024 * 1024), outfile)
|
||||||
std::io::BufWriter::new(outfile)
|
} else {
|
||||||
};
|
std::io::BufWriter::new(outfile)
|
||||||
std::io::copy(&mut file, &mut writer)?;
|
};
|
||||||
|
std::io::copy(&mut file, &mut writer)?;
|
||||||
|
}
|
||||||
|
|
||||||
// See `uv_extract::stream::unzip`. For simplicity, this is identical with the code there except for being
|
// See `uv_extract::stream::unzip`. For simplicity, this is identical with the code there except for being
|
||||||
// sync.
|
// sync.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue