aboutsummaryrefslogtreecommitdiff
path: root/import
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-01-22 03:07:51 +0100
committermetamuffin <metamuffin@disroot.org>2024-01-22 03:07:51 +0100
commitcd9a7f2f80465044fdafd992b574a3c951a68cbf (patch)
tree038605598b9beec9b504a5702ab37c36249f2ed2 /import
parent3a37d42e0c12d6a382849cca6cd2df63519b336e (diff)
downloadjellything-cd9a7f2f80465044fdafd992b574a3c951a68cbf.tar
jellything-cd9a7f2f80465044fdafd992b574a3c951a68cbf.tar.bz2
jellything-cd9a7f2f80465044fdafd992b574a3c951a68cbf.tar.zst
untested node ext import
Diffstat (limited to 'import')
-rw-r--r--import/src/lib.rs27
1 files changed, 24 insertions, 3 deletions
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