mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-06 12:10:02 +00:00
Rm download_and_extract_with_filter
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
e68eea35fe
commit
f82890cba3
2 changed files with 1 additions and 82 deletions
|
@ -86,36 +86,6 @@ pub async fn download_and_extract<P: AsRef<Path>>(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Download a file from the provided URL and extract part of it to
|
||||
/// the provided path.
|
||||
///
|
||||
/// * `filter` - It will pass the path of the file to it
|
||||
/// and only extract ones which filter returns `true`.
|
||||
pub async fn download_and_extract_with_filter<
|
||||
Filter: FnMut(&Path) -> bool + Send + 'static,
|
||||
P: AsRef<Path>,
|
||||
>(
|
||||
url: Url,
|
||||
fmt: TarBasedFmt,
|
||||
path: P,
|
||||
filter: Filter,
|
||||
) -> Result<(), BinstallError> {
|
||||
debug!("Downloading from: '{url}'");
|
||||
|
||||
let resp = create_request(url).await?;
|
||||
|
||||
let path = path.as_ref();
|
||||
debug!("Downloading to file: '{}'", path.display());
|
||||
|
||||
let stream = resp.bytes_stream();
|
||||
|
||||
extract_tar_based_stream_with_filter(stream, path, fmt, filter).await?;
|
||||
|
||||
debug!("Download OK, written to file: '{}'", path.display());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Download a file from the provided URL and extract part of it to
|
||||
/// the provided path.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue