diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:39:48 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:39:48 +0100 |
commit | 29a10b6fede6828e3da49272aefa5c8fe2c08078 (patch) | |
tree | 97f9596011cf09cbf0a8935e293db2cf7a8a30ce /tool/src | |
parent | af99c406af8ee47bee38708cf23e86af826e41ba (diff) | |
download | jellything-29a10b6fede6828e3da49272aefa5c8fe2c08078.tar jellything-29a10b6fede6828e3da49272aefa5c8fe2c08078.tar.bz2 jellything-29a10b6fede6828e3da49272aefa5c8fe2c08078.tar.zst |
tool: reimport client
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/main.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tool/src/main.rs b/tool/src/main.rs index 26865c6..47c9a53 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -11,6 +11,7 @@ pub mod migrate; use base64::Engine; use clap::{Parser, Subcommand, ValueEnum}; use import::import; +use jellyclient::{Instance, LoginDetails}; use jellycommon::{config::GlobalConfig, Node, NodeKind, NodePrivate, NodePublic}; use log::{info, warn}; use migrate::migrate; @@ -76,6 +77,16 @@ enum Action { mode: MigrateMode, save_location: PathBuf, }, + Reimport { + /// Path to global jellything config + config: PathBuf, + /// Custom hostname, the config's is used by default + #[arg(long)] + hostname: Option<String>, + /// Disable TLS. Dont use this. + #[arg(long)] + no_tls: bool, + }, } #[derive(Debug, Clone, Copy, PartialEq, ValueEnum)] @@ -147,6 +158,31 @@ fn main() -> anyhow::Result<()> { } a @ Action::New { .. } => import(a, args.dry), a @ Action::Migrate { .. } => migrate(a), + Action::Reimport { + config, + hostname, + no_tls, + } => tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() + .block_on(async move { + let config = serde_yaml::from_reader::<_, GlobalConfig>(File::open(config)?)?; + + let inst = Instance::new(hostname.unwrap_or(config.hostname.clone()), !no_tls); + info!("login"); + let session = inst + .login(LoginDetails { + drop_permissions: None, + expire: None, + password: config.admin_password, + username: config.admin_username, + }) + .await?; + + session.reimport().await?; + Ok(()) + }), } } |