mirror of https://github.com/astral-sh/uv
Avoid allocating a max-size buffer (#1123)
This seems potentially-dangerous with no upside.
This commit is contained in:
parent
39021263dd
commit
f946d46273
|
|
@ -50,9 +50,12 @@ pub async fn unzip_no_seek<R: tokio::io::AsyncRead + Unpin>(
|
||||||
fs_err::tokio::create_dir_all(parent).await?;
|
fs_err::tokio::create_dir_all(parent).await?;
|
||||||
}
|
}
|
||||||
let file = fs_err::tokio::File::create(path).await?;
|
let file = fs_err::tokio::File::create(path).await?;
|
||||||
let size =
|
let mut writer =
|
||||||
usize::try_from(entry.reader().entry().uncompressed_size()).unwrap_or(usize::MAX);
|
if let Ok(size) = usize::try_from(entry.reader().entry().uncompressed_size()) {
|
||||||
let mut writer = tokio::io::BufWriter::with_capacity(size, file);
|
tokio::io::BufWriter::with_capacity(size, file)
|
||||||
|
} else {
|
||||||
|
tokio::io::BufWriter::new(file)
|
||||||
|
};
|
||||||
let mut reader = entry.reader_mut().compat();
|
let mut reader = entry.reader_mut().compat();
|
||||||
tokio::io::copy(&mut reader, &mut writer).await?;
|
tokio::io::copy(&mut reader, &mut writer).await?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue