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>
This commit is contained in:
Jiahao XU 2022-06-18 18:24:01 +10:00
parent 9de8a4841f
commit a5879e3d65
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -40,13 +40,11 @@ where
pub async fn extract_bin<E>( pub async fn extract_bin<E>(
stream: impl Stream<Item = Result<Bytes, E>> + Unpin, stream: impl Stream<Item = Result<Bytes, E>> + Unpin,
output: &Path, path: &Path,
) -> Result<(), BinstallError> ) -> Result<(), BinstallError>
where where
BinstallError: From<E>, BinstallError: From<E>,
{ {
let path = output.to_owned();
extract_impl(stream, move |mut reader| { extract_impl(stream, move |mut reader| {
fs::create_dir_all(path.parent().unwrap())?; fs::create_dir_all(path.parent().unwrap())?;
@ -71,13 +69,11 @@ where
pub async fn extract_zip<E>( pub async fn extract_zip<E>(
stream: impl Stream<Item = Result<Bytes, E>> + Unpin, stream: impl Stream<Item = Result<Bytes, E>> + Unpin,
output: &Path, path: &Path,
) -> Result<(), BinstallError> ) -> Result<(), BinstallError>
where where
BinstallError: From<E>, BinstallError: From<E>,
{ {
let path = output.to_owned();
extract_impl(stream, move |mut reader| { extract_impl(stream, move |mut reader| {
fs::create_dir_all(path.parent().unwrap())?; fs::create_dir_all(path.parent().unwrap())?;
@ -88,21 +84,19 @@ where
// rewind it so that we can pass it to unzip // rewind it so that we can pass it to unzip
file.rewind()?; file.rewind()?;
unzip(file, &path) unzip(file, path)
}) })
.await .await
} }
pub async fn extract_tar_based_stream<E>( pub async fn extract_tar_based_stream<E>(
stream: impl Stream<Item = Result<Bytes, E>> + Unpin + 'static, stream: impl Stream<Item = Result<Bytes, E>> + Unpin + 'static,
output: &Path, path: &Path,
fmt: TarBasedFmt, fmt: TarBasedFmt,
) -> Result<(), BinstallError> ) -> Result<(), BinstallError>
where where
BinstallError: From<E>, BinstallError: From<E>,
{ {
let path = output.to_owned();
extract_impl(stream, move |reader| { extract_impl(stream, move |reader| {
fs::create_dir_all(path.parent().unwrap())?; fs::create_dir_all(path.parent().unwrap())?;