mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Refactor MultiFetcher.first_available
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
c393270899
commit
3d6679fd7d
1 changed files with 11 additions and 13 deletions
|
@ -63,16 +63,7 @@ impl MultiFetcher {
|
|||
let fetcher_cloned = fetcher.clone();
|
||||
|
||||
(
|
||||
AutoAbortJoinHandle(tokio::spawn(async move {
|
||||
fetcher.check().await.unwrap_or_else(|err| {
|
||||
debug!(
|
||||
"Error while checking fetcher {}: {}",
|
||||
fetcher.source_name(),
|
||||
err
|
||||
);
|
||||
false
|
||||
})
|
||||
})),
|
||||
AutoAbortJoinHandle(tokio::spawn(async move { fetcher.check().await })),
|
||||
fetcher_cloned,
|
||||
)
|
||||
})
|
||||
|
@ -80,7 +71,15 @@ impl MultiFetcher {
|
|||
|
||||
for (mut handle, fetcher) in handles {
|
||||
match (&mut handle.0).await {
|
||||
Ok(true) => return Some(fetcher),
|
||||
Ok(Ok(true)) => return Some(fetcher),
|
||||
Ok(Ok(false)) => (),
|
||||
Ok(Err(err)) => {
|
||||
debug!(
|
||||
"Error while checking fetcher {}: {}",
|
||||
fetcher.source_name(),
|
||||
err
|
||||
);
|
||||
}
|
||||
Err(join_err) => {
|
||||
debug!(
|
||||
"Error while checking fetcher {}: {}",
|
||||
|
@ -88,7 +87,6 @@ impl MultiFetcher {
|
|||
join_err
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +95,7 @@ impl MultiFetcher {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct AutoAbortJoinHandle(JoinHandle<bool>);
|
||||
struct AutoAbortJoinHandle(JoinHandle<Result<bool, BinstallError>>);
|
||||
|
||||
impl Drop for AutoAbortJoinHandle {
|
||||
fn drop(&mut self) {
|
||||
|
|
Loading…
Add table
Reference in a new issue