mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 18:36:30 +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 {
|
Qr::Backup2 {
|
||||||
node_addr,
|
node_addr,
|
||||||
auth_token,
|
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"),
|
_ => bail!("QR code for backup must be of type DCBACKUP2"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user