Refactor: Rm global var helpers::CLIENT

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-10 18:07:07 +10:00
parent 3c06c45792
commit fa63dbe5cf
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
6 changed files with 42 additions and 36 deletions

View file

@ -4,6 +4,7 @@ use std::time::Duration;
use cargo_toml::Manifest;
use crates_io_api::AsyncClient;
use log::debug;
use reqwest::Client;
use url::Url;
use super::find_version;
@ -16,6 +17,7 @@ use visitor::ManifestVisitor;
/// Fetch a crate Cargo.toml by name and version from crates.io
pub async fn fetch_crate_cratesio(
client: &Client,
name: &str,
version_req: &str,
) -> Result<Manifest<Meta>, BinstallError> {
@ -67,6 +69,7 @@ pub async fn fetch_crate_cratesio(
let manifest_dir_path: PathBuf = format!("{name}-{version_name}").into();
download_tar_based_and_visit(
client,
Url::parse(&crate_url)?,
TarBasedFmt::Tgz,
ManifestVisitor::new(manifest_dir_path),