Skip to content

Commit

Permalink
perf(tarball): use read_to_end
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Nov 4, 2023
1 parent 9c38751 commit cf7bb55
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/tarball/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl<'a> DownloadTarballToStore<'a> {
.map_err(TarballError::ReadTarballEntries)?
.filter(|entry| !entry.as_ref().unwrap().header().entry_type().is_dir())
.map(|entry| entry.expect("get entry"))
.map(|entry| {
.map(|mut entry| {
let cleaned_entry_path = entry
.path()
.expect("get path") // TODO: properly propagate this error
Expand All @@ -233,7 +233,8 @@ impl<'a> DownloadTarballToStore<'a> {
.into_os_string();
let file_mode = entry.header().mode().expect("get mode"); // TODO: properly propagate this error
let file_size = entry.header().size().ok();
let buffer = entry.bytes().collect::<Result<_, _>>().expect("read content"); // TODO: properly propagate this error
let mut buffer = Vec::with_capacity(entry.size() as usize);
entry.read_to_end(&mut buffer).expect("read content"); // TODO: properly propagate this error
FileInfo { cleaned_entry_path, file_mode, file_size, buffer }
})
.collect::<Vec<FileInfo>>()
Expand Down

0 comments on commit cf7bb55

Please sign in to comment.