mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Simplify extract_tar_based_stream_and_visit
Rm unused param `path` and the unnecessary `fs::create_dir_all` since the tar will not be extracted to disk. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
17fcac7e63
commit
e376b71cf4
2 changed files with 3 additions and 9 deletions
|
@ -109,7 +109,7 @@ pub async fn download_tar_based_and_visit<
|
|||
|
||||
let stream = resp.bytes_stream();
|
||||
|
||||
let visitor = extract_tar_based_stream_and_visit(stream, path, fmt, visitor).await?;
|
||||
let visitor = extract_tar_based_stream_and_visit(stream, fmt, visitor).await?;
|
||||
|
||||
debug!("Download OK, written to file: '{}'", path.display());
|
||||
|
||||
|
|
|
@ -233,21 +233,15 @@ where
|
|||
|
||||
pub async fn extract_tar_based_stream_and_visit<V: TarEntriesVisitor + Debug + Send + 'static, E>(
|
||||
stream: impl Stream<Item = Result<Bytes, E>> + Unpin,
|
||||
output: &Path,
|
||||
fmt: TarBasedFmt,
|
||||
mut visitor: V,
|
||||
) -> Result<V, BinstallError>
|
||||
where
|
||||
BinstallError: From<E>,
|
||||
{
|
||||
let path = output.to_owned();
|
||||
|
||||
extract_impl(stream, move |mut rx| {
|
||||
fs::create_dir_all(path.parent().unwrap())?;
|
||||
|
||||
extract_compressed_from_readable(ReadableRx::new(&mut rx), fmt, Op::Visit(&mut visitor))?;
|
||||
|
||||
Ok(visitor)
|
||||
extract_compressed_from_readable(ReadableRx::new(&mut rx), fmt, Op::Visit(&mut visitor))
|
||||
.map(|_| visitor)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue