mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 04:58:42 +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;
|
mod crate_name;
|
||||||
pub use crate_name::CrateName;
|
pub use crate_name::CrateName;
|
||||||
|
|
||||||
pub async fn await_task<T>(task: tokio::task::JoinHandle<T>) -> miette::Result<T> {
|
pub async fn await_task<T>(task: tokio::task::JoinHandle<miette::Result<T>>) -> miette::Result<T> {
|
||||||
task.await
|
match task.await {
|
||||||
.map_err(|join_err| miette::miette!("Task failed to join: {}", join_err))
|
Ok(res) => res,
|
||||||
|
Err(join_err) => Err(miette::miette!("Task failed to join: {}", join_err)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_jobserver_client() -> Result<jobserver::Client, BinstallError> {
|
pub fn create_jobserver_client() -> Result<jobserver::Client, BinstallError> {
|
||||||
|
|
|
@ -279,7 +279,7 @@ async fn entry() -> Result<()> {
|
||||||
// Confirm
|
// Confirm
|
||||||
let mut resolutions = Vec::with_capacity(tasks.len());
|
let mut resolutions = Vec::with_capacity(tasks.len());
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
resolutions.push(await_task(task).await??);
|
resolutions.push(await_task(task).await?);
|
||||||
}
|
}
|
||||||
|
|
||||||
uithread.confirm().await?;
|
uithread.confirm().await?;
|
||||||
|
@ -308,7 +308,7 @@ async fn entry() -> Result<()> {
|
||||||
let jobserver_client = jobserver_client.clone();
|
let jobserver_client = jobserver_client.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
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
|
install(resolution, opts, temp_dir_path, target, jobserver_client).await
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -316,7 +316,7 @@ async fn entry() -> Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
await_task(task).await??;
|
await_task(task).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.no_cleanup {
|
if !opts.no_cleanup {
|
||||||
|
|
Loading…
Add table
Reference in a new issue