mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 22:36:30 +03:00
Report imex and configure success/failure after freeing ongoing
Otherwise it's possible that library user (e.g. test) tries to start another ongoing process when previous one is not freed yet.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
- python: avoid exceptions when messages/contacts/chats are compared with `None`
|
- python: avoid exceptions when messages/contacts/chats are compared with `None`
|
||||||
- node: wait for the event loop to stop before destroying contexts #3431
|
- node: wait for the event loop to stop before destroying contexts #3431
|
||||||
- emit configuration errors via event on failure #3433
|
- emit configuration errors via event on failure #3433
|
||||||
|
- report configure and imex success/failure after freeing ongoing process #3442
|
||||||
|
|
||||||
### API-Changes
|
### API-Changes
|
||||||
- python: added `Message.get_status_updates()` #3416
|
- python: added `Message.get_status_updates()` #3416
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ impl Context {
|
|||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
self.free_ongoing().await;
|
||||||
|
|
||||||
if let Err(err) = res.as_ref() {
|
if let Err(err) = res.as_ref() {
|
||||||
progress!(
|
progress!(
|
||||||
self,
|
self,
|
||||||
@@ -93,8 +95,6 @@ impl Context {
|
|||||||
progress!(self, 1000);
|
progress!(self, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.free_ongoing().await;
|
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
src/imex.rs
26
src/imex.rs
@@ -86,22 +86,7 @@ pub async fn imex(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let cancel = context.alloc_ongoing().await?;
|
let cancel = context.alloc_ongoing().await?;
|
||||||
|
|
||||||
let res = async {
|
let res = imex_inner(context, what, path, passphrase)
|
||||||
let success = imex_inner(context, what, path, passphrase).await;
|
|
||||||
match success {
|
|
||||||
Ok(()) => {
|
|
||||||
info!(context, "IMEX successfully completed");
|
|
||||||
context.emit_event(EventType::ImexProgress(1000));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
// We are using Anyhow's .context() and to show the inner error, too, we need the {:#}:
|
|
||||||
error!(context, "{:#}", err);
|
|
||||||
context.emit_event(EventType::ImexProgress(0));
|
|
||||||
bail!("IMEX FAILED to complete: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.race(async {
|
.race(async {
|
||||||
cancel.recv().await.ok();
|
cancel.recv().await.ok();
|
||||||
Err(format_err!("canceled"))
|
Err(format_err!("canceled"))
|
||||||
@@ -110,6 +95,15 @@ pub async fn imex(
|
|||||||
|
|
||||||
context.free_ongoing().await;
|
context.free_ongoing().await;
|
||||||
|
|
||||||
|
if let Err(err) = res.as_ref() {
|
||||||
|
// We are using Anyhow's .context() and to show the inner error, too, we need the {:#}:
|
||||||
|
error!(context, "IMEX failed to complete: {:#}", err);
|
||||||
|
context.emit_event(EventType::ImexProgress(0));
|
||||||
|
} else {
|
||||||
|
info!(context, "IMEX successfully completed");
|
||||||
|
context.emit_event(EventType::ImexProgress(1000));
|
||||||
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user