integrate backup sending via iroh into the repl

This commit is contained in:
dignifiedquire
2022-07-07 17:34:40 +02:00
parent 0e06bcb182
commit 9f7e962832
10 changed files with 100 additions and 36 deletions

View File

@@ -335,6 +335,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
continue-key-transfer <msg-id> <setup-code>\n\
has-backup\n\
export-backup\n\
send-backup\n\
import-backup <backup-file>\n\
export-keys\n\
import-keys\n\
@@ -477,6 +478,19 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
.await?;
println!("Exported to {}.", dir.to_string_lossy());
}
"send-backup" => {
let dir = dirs::home_dir().unwrap_or_default();
let (sender, transfer) =
send_backup(&context, dir.as_ref(), Some(arg2.to_string())).await?;
let ticket_bytes = transfer.ticket().as_bytes();
println!(
"Ticket: {}",
multibase::encode(multibase::Base::Base64, &ticket_bytes)
);
tokio::time::sleep(std::time::Duration::from_secs(100)).await;
sender.close().await?;
}
"import-backup" => {
ensure!(!arg1.is_empty(), "Argument <backup-file> missing.");
imex(