diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/import.rs | 18 | ||||
-rw-r--r-- | server/src/routes/ui/account/admin.rs | 7 |
2 files changed, 16 insertions, 9 deletions
diff --git a/server/src/import.rs b/server/src/import.rs index 3b45f14..d72690c 100644 --- a/server/src/import.rs +++ b/server/src/import.rs @@ -100,14 +100,15 @@ pub async fn import_path( info!("loading {path:?}"); let datafile = File::open(path.clone()).context("cant load metadata")?; let mut data: Node = serde_json::from_reader(datafile).context("invalid metadata")?; - let identifier = path - .file_name() - .unwrap() - .to_str() - .unwrap() - .strip_suffix(".jelly") - .unwrap() - .to_string(); + let identifier = data.private.id.clone().unwrap_or_else(|| { + path.file_name() + .unwrap() + .to_str() + .unwrap() + .strip_suffix(".jelly") + .unwrap() + .to_string() + }); if let Some(io) = data.private.import.take() { let session = fed @@ -152,6 +153,7 @@ async fn import_remote( backdrop: Some(AssetLocation::Cache(backdrop)), poster: Some(AssetLocation::Cache(poster)), import: None, + id: None, source: Some(MediaSource::Remote { host: opts.host.clone(), remote_id: opts.id.clone(), diff --git a/server/src/routes/ui/account/admin.rs b/server/src/routes/ui/account/admin.rs index d0ad433..f1520b7 100644 --- a/server/src/routes/ui/account/admin.rs +++ b/server/src/routes/ui/account/admin.rs @@ -17,6 +17,7 @@ use crate::{ use anyhow::anyhow; use rand::Rng; use rocket::{form::Form, get, post, FromForm, State}; +use std::time::Instant; #[get("/account/admin/dashboard")] pub fn r_account_admin_dashboard( @@ -141,9 +142,13 @@ pub async fn r_account_admin_import( if !session.user.admin { Err(anyhow!("you not admin"))? } + let t = Instant::now(); let r = import(&database, &federation).await; admin_dashboard( &database, - Some(r.map_err(|e| e.into()).map(|_| "Import successful".into())), + Some( + r.map_err(|e| e.into()) + .map(|_| format!("Import successful; took {:?}", t.elapsed())), + ), ) } |