From d6c24eb9f6ea339de255ae34a94cfac92d097803 Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 30 Jan 2024 15:40:36 +0000 Subject: [PATCH] Make Accounts::background_fetch() not return Result --- deltachat-ffi/src/lib.rs | 16 ++++------------ deltachat-jsonrpc/src/api.rs | 5 ++--- src/accounts.rs | 5 +---- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 32c0a3ba45..6f28a89b96 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -4915,19 +4915,11 @@ pub unsafe extern "C" fn dc_accounts_background_fetch( let accounts = &*accounts; block_on(async move { let accounts = accounts.read().await; - match accounts + accounts .background_fetch(Duration::from_secs(timeout_in_seconds)) - .await - { - Ok(()) => 1, - Err(err) => { - accounts.emit_event(EventType::Error(format!( - "Failed to do background fetch: {err:#}" - ))); - 0 - } - } - }) + .await; + }); + 1 } #[no_mangle] diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 85cb1c7b69..e2bf6c62f9 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -233,8 +233,7 @@ impl CommandApi { /// Performs a background fetch for all accounts in parallel with a timeout. /// - /// The `AccountsBackgroundFetchDone` event is emitted at the end - /// if the method returns sucessfully, even in case of timeout. + /// The `AccountsBackgroundFetchDone` event is emitted at the end even in case of timeout. /// Process all events until you get this one and you can safely return to the background /// without forgetting to create notifications caused by timing race conditions. async fn accounts_background_fetch(&self, timeout_in_seconds: f64) -> Result<()> { @@ -242,7 +241,7 @@ impl CommandApi { .write() .await .background_fetch(std::time::Duration::from_secs_f64(timeout_in_seconds)) - .await?; + .await; Ok(()) } diff --git a/src/accounts.rs b/src/accounts.rs index 99053719cc..626d279eff 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -317,9 +317,7 @@ impl Accounts { /// The `AccountsBackgroundFetchDone` event is emitted at the end, /// process all events until you get this one and you can safely return to the background /// without forgetting to create notifications caused by timing race conditions. - /// - /// On error no `AccountsBackgroundFetchDone` event is emitted. - pub async fn background_fetch(&self, timeout: std::time::Duration) -> Result<()> { + pub async fn background_fetch(&self, timeout: std::time::Duration) { if let Err(_err) = tokio::time::timeout(timeout, self.background_fetch_without_timeout()).await { @@ -328,7 +326,6 @@ impl Accounts { )); } self.emit_event(EventType::AccountsBackgroundFetchDone); - Ok(()) } /// Emits a single event.