mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-03 09:32:55 +00:00
Run artifact discover in sequential instead of in parallel (#1796)
* Perform artifact discovery in sequential Run different `fetcher.find()` in sequential * FuturesResolver: Fallback to other future if one error * Fix typo * Apply cargo fmt * Parallelise `<QuickInstall as Fetcher>::find` Check for signature in parallel to the package * Download signature in `<QuickInstall as Fetcher>::find` So that the signature download can be done in parallel. * Bump msrv for binstalk-fetchers to 1.70 * Update crates/binstalk-fetchers/src/futures_resolver.rs Co-authored-by: Félix Saparelli <felix@passcod.name> Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> * cargo fmt Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Félix Saparelli <felix@passcod.name>
This commit is contained in:
parent
ebdca1126e
commit
ac7bac651d
7 changed files with 128 additions and 54 deletions
|
@ -1,6 +1,11 @@
|
|||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering::Relaxed},
|
||||
Once,
|
||||
#![allow(unused)]
|
||||
|
||||
use std::{
|
||||
future::Future,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering::Relaxed},
|
||||
Once,
|
||||
},
|
||||
};
|
||||
|
||||
pub(super) use binstalk_downloader::{
|
||||
|
@ -76,3 +81,33 @@ pub(super) async fn does_url_exist(
|
|||
|
||||
Ok(Box::pin(client.remote_gettable(url.clone())).await?)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct AutoAbortJoinHandle<T>(JoinHandle<T>);
|
||||
|
||||
impl<T> AutoAbortJoinHandle<T>
|
||||
where
|
||||
T: Send + 'static,
|
||||
{
|
||||
pub(super) fn spawn<F>(future: F) -> Self
|
||||
where
|
||||
F: Future<Output = T> + Send + 'static,
|
||||
{
|
||||
Self(tokio::spawn(future))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for AutoAbortJoinHandle<T> {
|
||||
fn drop(&mut self) {
|
||||
self.0.abort();
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> AutoAbortJoinHandle<Result<T, E>>
|
||||
where
|
||||
E: Into<FetchError>,
|
||||
{
|
||||
pub(super) async fn flattened_join(mut self) -> Result<T, FetchError> {
|
||||
(&mut self.0).await?.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue