diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 5ecb31709..32c0a3ba4 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -4916,7 +4916,7 @@ pub unsafe extern "C" fn dc_accounts_background_fetch( block_on(async move { let accounts = accounts.read().await; match accounts - .background_fetch_with_timeout(Duration::from_secs(timeout_in_seconds)) + .background_fetch(Duration::from_secs(timeout_in_seconds)) .await { Ok(()) => 1, diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index c03400265..5b98bf12a 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -240,7 +240,7 @@ impl CommandApi { self.accounts .write() .await - .background_fetch_with_timeout(std::time::Duration::from_secs_f64(timeout_in_seconds)) + .background_fetch(std::time::Duration::from_secs_f64(timeout_in_seconds)) .await?; Ok(()) } diff --git a/src/accounts.rs b/src/accounts.rs index 41ca2f436..3454c637a 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -294,12 +294,9 @@ impl Accounts { /// Performs a background fetch for all accounts in parallel. /// - /// If you need a timeout, then use [Accounts::background_fetch_with_timeout] instead. - /// - /// 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 forgeting to create notifications caused by timing race conditions. - pub async fn background_fetch(&self) { + /// This is an auxiliary function and not part of public API. + /// Use [Accounts::background_fetch] instead. + async fn background_fetch_without_timeout(&self) { async fn background_fetch_and_log_error(account: Context) { if let Err(error) = account.background_fetch().await { warn!(account, "{error:#}"); @@ -313,19 +310,15 @@ impl Accounts { .map(background_fetch_and_log_error), ) .await; - - self.emit_event(EventType::AccountsBackgroundFetchDone); } /// Performs a background fetch for all accounts in parallel with a timeout. /// - /// If you want no timeout, then use [Accounts::background_fetch] instead. - /// /// 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 forgeting to create notifications caused by timing race conditions. - pub async fn background_fetch_with_timeout(&self, timeout: std::time::Duration) -> Result<()> { - let result = tokio::time::timeout(timeout, self.background_fetch()).await; + pub async fn background_fetch(&self, timeout: std::time::Duration) -> Result<()> { + let result = tokio::time::timeout(timeout, self.background_fetch_without_timeout()).await; self.emit_event(EventType::AccountsBackgroundFetchDone); result.map_err(|err| err.into()) }