From 29a10b6fede6828e3da49272aefa5c8fe2c08078 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 16 Dec 2023 01:39:48 +0100 Subject: tool: reimport client --- client/src/lib.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'client/src') diff --git a/client/src/lib.rs b/client/src/lib.rs index 61365a3..b80f705 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -5,7 +5,7 @@ */ use anyhow::Result; use jellycommon::user::UserPermission; -use log::debug; +use log::{debug, info}; use reqwest::{ header::{HeaderMap, HeaderValue}, Client, @@ -100,7 +100,10 @@ impl Session { debug!("downloading asset {role:?} for {id:?}"); let mut r = self .client - .get(format!("{}/n/{id}/asset?role={role}&width={width}", self.instance.base())) + .get(format!( + "{}/n/{id}/asset?role={role}&width={width}", + self.instance.base() + )) .send() .await?; while let Some(chunk) = r.chunk().await? { @@ -109,6 +112,17 @@ impl Session { Ok(()) } + pub async fn reimport(&self) -> Result<()> { + // TODO error handling + info!("reimport"); + self.client + .post(format!("{}/admin/import", self.instance.base())) + .send() + .await?; + info!("done"); + Ok(()) + } + pub fn stream(&self, id: &str, stream_spec: &StreamSpec) -> String { format!( "{}/n/{}/stream?{}&{}", -- cgit v1.2.3-70-g09d2