mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Simplify helpers::await_task
API
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
072253ebae
commit
b223990bb1
2 changed files with 8 additions and 6 deletions
|
@ -39,9 +39,11 @@ pub use tls_version::TLSVersion;
|
|||
mod crate_name;
|
||||
pub use crate_name::CrateName;
|
||||
|
||||
pub async fn await_task<T>(task: tokio::task::JoinHandle<T>) -> miette::Result<T> {
|
||||
task.await
|
||||
.map_err(|join_err| miette::miette!("Task failed to join: {}", join_err))
|
||||
pub async fn await_task<T>(task: tokio::task::JoinHandle<miette::Result<T>>) -> miette::Result<T> {
|
||||
match task.await {
|
||||
Ok(res) => res,
|
||||
Err(join_err) => Err(miette::miette!("Task failed to join: {}", join_err)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_jobserver_client() -> Result<jobserver::Client, BinstallError> {
|
||||
|
|
|
@ -279,7 +279,7 @@ async fn entry() -> Result<()> {
|
|||
// Confirm
|
||||
let mut resolutions = Vec::with_capacity(tasks.len());
|
||||
for task in tasks {
|
||||
resolutions.push(await_task(task).await??);
|
||||
resolutions.push(await_task(task).await?);
|
||||
}
|
||||
|
||||
uithread.confirm().await?;
|
||||
|
@ -308,7 +308,7 @@ async fn entry() -> Result<()> {
|
|||
let jobserver_client = jobserver_client.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
let resolution = await_task(task).await??;
|
||||
let resolution = await_task(task).await?;
|
||||
install(resolution, opts, temp_dir_path, target, jobserver_client).await
|
||||
})
|
||||
})
|
||||
|
@ -316,7 +316,7 @@ async fn entry() -> Result<()> {
|
|||
};
|
||||
|
||||
for task in tasks {
|
||||
await_task(task).await??;
|
||||
await_task(task).await?;
|
||||
}
|
||||
|
||||
if !opts.no_cleanup {
|
||||
|
|
Loading…
Add table
Reference in a new issue