diff --git a/src/drivers.rs b/src/drivers.rs index 49b615c1..f45fa7c7 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -5,6 +5,7 @@ use std::time::Duration; use crates_io_api::AsyncClient; use log::debug; use semver::{Version, VersionReq}; +use url::Url; use crate::{helpers::*, BinstallError, PkgFmt}; @@ -103,7 +104,7 @@ pub async fn fetch_crate_cratesio( debug!("Fetching crate from: {crate_url}"); // Download crate - download(&crate_url, &tgz_path).await?; + download(Url::parse(&crate_url)?, &tgz_path).await?; // Decompress downloaded tgz debug!("Decompressing crate archive"); diff --git a/src/fetchers/gh_crate_meta.rs b/src/fetchers/gh_crate_meta.rs index e38d7ae1..4f043f41 100644 --- a/src/fetchers/gh_crate_meta.rs +++ b/src/fetchers/gh_crate_meta.rs @@ -43,7 +43,7 @@ impl super::Fetcher for GhCrateMeta { async fn fetch(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.url()?; info!("Downloading package from: '{url}'"); - download(url.as_str(), dst).await + download(url, dst).await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/fetchers/quickinstall.rs b/src/fetchers/quickinstall.rs index ec83493c..1e3e7821 100644 --- a/src/fetchers/quickinstall.rs +++ b/src/fetchers/quickinstall.rs @@ -39,7 +39,7 @@ impl super::Fetcher for QuickInstall { async fn fetch(&self, dst: &Path) -> Result<(), BinstallError> { let url = self.package_url(); info!("Downloading package from: '{url}'"); - download(&url, &dst).await + download(Url::parse(&url)?, &dst).await } fn pkg_fmt(&self) -> PkgFmt { diff --git a/src/helpers.rs b/src/helpers.rs index 27b22551..9f670826 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -41,8 +41,7 @@ pub async fn remote_exists(url: Url, method: Method) -> Result>(url: &str, path: P) -> Result<(), BinstallError> { - let url = Url::parse(url)?; +pub async fn download>(url: Url, path: P) -> Result<(), BinstallError> { debug!("Downloading from: '{url}'"); let resp = reqwest::get(url.clone())