use crate::cli_core::artifact::{tar_gz_decode, tar_gz_encode};
use crate::cli_core::core::NormalizedPath;
async fn join_io<T>(
handle: tokio::task::JoinHandle<Result<T, std::io::Error>>,
) -> Result<T, std::io::Error> {
handle
.await
.map_err(|err| std::io::Error::other(format!("blocking archive task failed: {err}")))?
}
pub(crate) async fn tar_gz_encode_async(src: NormalizedPath) -> Result<Vec<u8>, std::io::Error> {
join_io(tokio::task::spawn_blocking(move || {
tar_gz_encode(src.as_path())
}))
.await
}
pub(crate) async fn tar_gz_decode_async(
data: Vec<u8>,
dest: NormalizedPath,
) -> Result<(), std::io::Error> {
join_io(tokio::task::spawn_blocking(move || {
tar_gz_decode(&data, dest.as_path())
}))
.await
}