mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-17 09:20:03 +00:00
Use download_and_extract
in fetchers
to improve efficiency by avoiding disk io (except for `PkgFmt::Zip` and `PkgFmt::Bin`) and run the compresser in parallel to the downloader. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
b6bfd40c3a
commit
c9b0d45a24
4 changed files with 19 additions and 24 deletions
src/fetchers
|
@ -7,7 +7,7 @@ use serde::Serialize;
|
|||
use url::Url;
|
||||
|
||||
use super::Data;
|
||||
use crate::{download, remote_exists, BinstallError, PkgFmt, Template};
|
||||
use crate::{download_and_extract, remote_exists, BinstallError, PkgFmt, Template};
|
||||
|
||||
pub struct GhCrateMeta {
|
||||
data: Data,
|
||||
|
@ -40,10 +40,10 @@ impl super::Fetcher for GhCrateMeta {
|
|||
remote_exists(url, Method::HEAD).await
|
||||
}
|
||||
|
||||
async fn fetch(&self, dst: &Path) -> Result<(), BinstallError> {
|
||||
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
||||
let url = self.url()?;
|
||||
info!("Downloading package from: '{url}'");
|
||||
download(url.as_str(), dst).await
|
||||
download_and_extract::<_, 0>(url, self.pkg_fmt(), dst, None).await
|
||||
}
|
||||
|
||||
fn pkg_fmt(&self) -> PkgFmt {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue