Refactor: Mv debug! into create_request

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-21 13:47:00 +10:00
parent ad41756daa
commit 74a6e137be
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -52,6 +52,8 @@ pub async fn remote_exists(url: Url, method: Method) -> Result<bool, BinstallErr
async fn create_request( async fn create_request(
url: Url, url: Url,
) -> Result<impl Stream<Item = reqwest::Result<Bytes>>, BinstallError> { ) -> Result<impl Stream<Item = reqwest::Result<Bytes>>, BinstallError> {
debug!("Downloading from: '{url}'");
reqwest::get(url.clone()) reqwest::get(url.clone())
.await .await
.and_then(|r| r.error_for_status()) .and_then(|r| r.error_for_status())
@ -69,8 +71,6 @@ pub async fn download_and_extract<P: AsRef<Path>>(
fmt: PkgFmt, fmt: PkgFmt,
path: P, path: P,
) -> Result<(), BinstallError> { ) -> Result<(), BinstallError> {
debug!("Downloading from: '{url}'");
let stream = create_request(url).await?; let stream = create_request(url).await?;
let path = path.as_ref(); let path = path.as_ref();
@ -97,8 +97,6 @@ pub async fn download_tar_based_and_visit<V: TarEntriesVisitor + Debug + Send +
fmt: TarBasedFmt, fmt: TarBasedFmt,
visitor: V, visitor: V,
) -> Result<V, BinstallError> { ) -> Result<V, BinstallError> {
debug!("Downloading from: '{url}'");
let stream = create_request(url).await?; let stream = create_request(url).await?;
debug!("Downloading and extracting then in-memory processing"); debug!("Downloading and extracting then in-memory processing");