From cd9a7f2f80465044fdafd992b574a3c951a68cbf Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 22 Jan 2024 03:07:51 +0100 Subject: untested node ext import --- import/src/lib.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'import/src') diff --git a/import/src/lib.rs b/import/src/lib.rs index 8347833..46b98a9 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -115,6 +115,15 @@ pub fn merge_nodes(db: &DataAcid) -> anyhow::Result<()> { node.public.id = Some(id.value().to_owned()); node.public.path = vec![]; // will be reconstructed in the next pass + // TODO this discardes a lot of information. maybe change this. + if let Some(media) = &node.public.media { + for t in &media.tracks { + if let Some(host) = t.federated.first() { + node.public.federated = Some(host.to_string()) + } + } + } + { let txn_write = db.inner.begin_write()?; let mut t_node = txn_write.open_table(T_NODE)?; @@ -633,14 +642,25 @@ async fn import_remote( txn.commit()?; Ok(()) }; + let insert_node_ext = move |id: &str, n: ExtendedNode| -> anyhow::Result<()> { + // TODO merge this + let txn = db.inner.begin_write()?; + let mut table = txn.open_table(T_NODE_EXTENDED)?; + table.insert(id, Ser(n))?; + drop(table); + txn.commit()?; + Ok(()) + }; + let _permit = SEM_REMOTE_IMPORT.acquire().await.unwrap(); info!("loading federated node {id:?}"); let mut node = session.node(&id).await.context("fetching remote node")?; + let node_ext = session + .node_extended(&id) + .await + .context("fetching extended remote node")?; - // if node.federated.as_ref() == Some(&CONF.hostname) { - // return Ok(()); - // } let track_sources = if let Some(media) = &mut node.media { let mut track_sources = Vec::new(); for (i, t) in media.tracks.iter_mut().enumerate() { @@ -671,6 +691,7 @@ async fn import_remote( debug!("adding {id}"); insert_node(&id, node.clone())?; + insert_node_ext(&id, node_ext)?; let mut children: FuturesUnordered<_> = node .public -- cgit v1.2.3-70-g09d2