mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-02 02:00:03 +00:00
Impl new fn helpers::download_tar_based_and_visit
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
4892d8bf3a
commit
f8c8c66f57
2 changed files with 60 additions and 1 deletions
|
@ -282,3 +282,29 @@ where
|
|||
})
|
||||
.await
|
||||
}
|
||||
|
||||
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,
|
||||
&*path,
|
||||
Some(&mut visitor),
|
||||
)?;
|
||||
|
||||
Ok(visitor)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue