aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock25
-rw-r--r--client/src/lib.rs5
-rw-r--r--server/Cargo.toml1
-rw-r--r--server/src/import.rs12
4 files changed, 41 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index afaa45e..5422a63 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -826,6 +826,7 @@ checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
dependencies = [
"futures-channel",
"futures-core",
+ "futures-executor",
"futures-io",
"futures-sink",
"futures-task",
@@ -849,6 +850,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
[[package]]
+name = "futures-executor"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
name = "futures-io"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -870,6 +882,17 @@ dependencies = [
]
[[package]]
+name = "futures-macro"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.28",
+]
+
+[[package]]
name = "futures-sink"
version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -890,6 +913,7 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-io",
+ "futures-macro",
"futures-sink",
"futures-task",
"memchr",
@@ -1266,6 +1290,7 @@ dependencies = [
"chashmap",
"chrono",
"env_logger",
+ "futures",
"jellyclient",
"jellycommon",
"jellyremuxer",
diff --git a/client/src/lib.rs b/client/src/lib.rs
index b208525..462dcb8 100644
--- a/client/src/lib.rs
+++ b/client/src/lib.rs
@@ -1,3 +1,8 @@
+/*
+ This file is part of jellything (https://codeberg.org/metamuffin/jellything)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2023 metamuffin <metamuffin.org>
+*/
use anyhow::Result;
use jellycommon::NodePublic;
use reqwest::{
diff --git a/server/Cargo.toml b/server/Cargo.toml
index 6648b80..d800983 100644
--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -27,6 +27,7 @@ aes-gcm-siv = "0.11.1"
async-std = "1.12.0"
async-recursion = "1.0.4"
+futures = "0.3.28"
tokio = { version = "1.29.1", features = ["io-util"] }
tokio-util = { version = "0.7.8", features = ["io", "io-util"] }
diff --git a/server/src/import.rs b/server/src/import.rs
index 6ea8268..374c2c7 100644
--- a/server/src/import.rs
+++ b/server/src/import.rs
@@ -7,6 +7,7 @@ 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 jellyclient::Session;
use jellycommon::{AssetLocation, MediaSource, Node, NodePrivate, RemoteImportOptions};
use log::{debug, error, info};
@@ -55,10 +56,17 @@ pub async fn import_path(
}
});
let identifier = path.file_name().unwrap().to_str().unwrap().to_string();
+
+ let all = join_all(
+ children_paths
+ .into_iter()
+ .map(|p| import_path(p, db, fed, Some(identifier.clone()))),
+ )
+ .await;
+
let mut children_ids = Vec::new();
let mut errs = 0;
- for p in children_paths {
- let k = import_path(p, db, fed, Some(identifier.clone())).await;
+ for k in all {
match k {
core::result::Result::Ok((els, errs2)) => {
errs += errs2;