mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 22:46:29 +03:00
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:
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user