diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/import.rs | 31 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 2 |
2 files changed, 22 insertions, 11 deletions
diff --git a/server/src/import.rs b/server/src/import.rs index 8908c00..6e422cd 100644 --- a/server/src/import.rs +++ b/server/src/import.rs @@ -106,7 +106,7 @@ pub async fn import_path( .to_string() }); - if let Some(io) = data.private.import.take() { + let idents = if let Some(io) = data.private.import.take() { let session = fed .get_session(&io.host) .await @@ -114,13 +114,14 @@ pub async fn import_path( import_remote(io, db, &session, identifier.clone(), parent) .await - .context("federated import")?; + .context("federated import")? } else { debug!("adding {identifier}"); data.public.parent = parent; db.node.insert(&identifier, &data)?; - } - Ok((vec![identifier], 0)) + vec![identifier] + }; + Ok((idents, 0)) } else { bail!("did somebody really put a fifo or socket in the library?!") } @@ -130,14 +131,18 @@ static SEM_REMOTE_IMPORT: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new( #[async_recursion] async fn import_remote( - opts: RemoteImportOptions, + mut opts: RemoteImportOptions, db: &Database, session: &Session, identifier: String, parent: Option<String>, -) -> anyhow::Result<()> { +) -> anyhow::Result<Vec<String>> { let _permit = SEM_REMOTE_IMPORT.acquire().await.unwrap(); info!("loading federated node {identifier:?}"); + + let flatten = opts.flatten; + opts.flatten = false; + let node = session .node(&opts.id) .await @@ -148,7 +153,7 @@ async fn import_remote( drop(_permit); - let child_parent = if opts.flatten { + let child_parent = if flatten { parent } else { let mut node = Node { @@ -194,9 +199,15 @@ async fn import_remote( }) .collect(); - while let Some(_) = children.next().await {} - - Ok(()) + let mut children_idents = Vec::new(); + while let Some(r) = children.next().await { + children_idents.extend(r?); + } + Ok(if flatten { + children_idents + } else { + vec![identifier] + }) } async fn cache_federation_asset( diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index cfc633b..008daf0 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -59,7 +59,7 @@ pub async fn r_library_node_filter( c.to_owned(), db.node .get(c)? - .ok_or(anyhow!("child does not exist"))? + .ok_or(anyhow!("child does not exist: {c}"))? .public, )) }) |