diff options
Diffstat (limited to 'server/src/import.rs')
-rw-r--r-- | server/src/import.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/server/src/import.rs b/server/src/import.rs index d72690c..872681f 100644 --- a/server/src/import.rs +++ b/server/src/import.rs @@ -7,7 +7,11 @@ use crate::{database::Database, federation::Federation, CONF}; use anyhow::{anyhow, bail, Context, Ok}; use async_recursion::async_recursion; use base64::Engine; -use futures::future::join_all; +use futures::{ + future::join_all, + stream::{FuturesOrdered, FuturesUnordered}, + StreamExt, +}; use jellyclient::Session; use jellycommon::{AssetLocation, MediaSource, Node, NodePrivate, RemoteImportOptions}; use log::{debug, error, info}; @@ -63,16 +67,14 @@ pub async fn import_path( .ok_or(anyhow!("non-root node requires parent"))? }; - let all = join_all( - children_paths - .into_iter() - .map(|p| import_path(p, db, fed, Some(identifier.clone()))), - ) - .await; + let mut all: FuturesUnordered<_> = children_paths + .into_iter() + .map(|p| import_path(p, db, fed, Some(identifier.clone()))) + .collect(); let mut children_ids = Vec::new(); let mut errs = 0; - for k in all { + while let Some(k) = all.next().await { match k { core::result::Result::Ok((els, errs2)) => { errs += errs2; |