fix: make backup reception cancellable by stopping ongoing process

This is already documented in JSON-RPC API,
but in fact ongoing process was not allocated.
This commit is contained in:
link2xt
2024-10-05 09:32:56 +00:00
parent c4d07ab99e
commit a592a470cf

View File

@@ -345,7 +345,17 @@ pub async fn get_backup(context: &Context, qr: Qr) -> Result<()> {
Qr::Backup2 {
node_addr,
auth_token,
} => get_backup2(context, node_addr, auth_token).await?,
} => {
let cancel_token = context.alloc_ongoing().await?;
let res = get_backup2(context, node_addr, auth_token)
.race(async {
cancel_token.recv().await.ok();
Err(format_err!("Backup reception cancelled"))
})
.await;
context.free_ongoing().await;
res?;
}
_ => bail!("QR code for backup must be of type DCBACKUP2"),
}
Ok(())