From a5879e3d6537edaa4439fdfe951003ec5d321201 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Sat, 18 Jun 2022 18:24:01 +1000 Subject: [PATCH] Rm unnecessary `to_owned` call in `extract_*` It was called before because `spawn_blocking` requires that, but we now switches to `block_in_place` which no longer needs this. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- src/helpers/async_extracter.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/helpers/async_extracter.rs b/src/helpers/async_extracter.rs index 634df7e0..e1448776 100644 --- a/src/helpers/async_extracter.rs +++ b/src/helpers/async_extracter.rs @@ -40,13 +40,11 @@ where pub async fn extract_bin<E>( stream: impl Stream<Item = Result<Bytes, E>> + Unpin, - output: &Path, + path: &Path, ) -> Result<(), BinstallError> where BinstallError: From<E>, { - let path = output.to_owned(); - extract_impl(stream, move |mut reader| { fs::create_dir_all(path.parent().unwrap())?; @@ -71,13 +69,11 @@ where pub async fn extract_zip<E>( stream: impl Stream<Item = Result<Bytes, E>> + Unpin, - output: &Path, + path: &Path, ) -> Result<(), BinstallError> where BinstallError: From<E>, { - let path = output.to_owned(); - extract_impl(stream, move |mut reader| { fs::create_dir_all(path.parent().unwrap())?; @@ -88,21 +84,19 @@ where // rewind it so that we can pass it to unzip file.rewind()?; - unzip(file, &path) + unzip(file, path) }) .await } pub async fn extract_tar_based_stream<E>( stream: impl Stream<Item = Result<Bytes, E>> + Unpin + 'static, - output: &Path, + path: &Path, fmt: TarBasedFmt, ) -> Result<(), BinstallError> where BinstallError: From<E>, { - let path = output.to_owned(); - extract_impl(stream, move |reader| { fs::create_dir_all(path.parent().unwrap())?;