Skip to content

Commit ea666f1

Browse files
link2xtr10s
authored andcommitted
Hide background_fetch_without_timeout from public API
1 parent 5bb80f9 commit ea666f1

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

deltachat-ffi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4916,7 +4916,7 @@ pub unsafe extern "C" fn dc_accounts_background_fetch(
49164916
block_on(async move {
49174917
let accounts = accounts.read().await;
49184918
match accounts
4919-
.background_fetch_with_timeout(Duration::from_secs(timeout_in_seconds))
4919+
.background_fetch(Duration::from_secs(timeout_in_seconds))
49204920
.await
49214921
{
49224922
Ok(()) => 1,

deltachat-jsonrpc/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl CommandApi {
240240
self.accounts
241241
.write()
242242
.await
243-
.background_fetch_with_timeout(std::time::Duration::from_secs_f64(timeout_in_seconds))
243+
.background_fetch(std::time::Duration::from_secs_f64(timeout_in_seconds))
244244
.await?;
245245
Ok(())
246246
}

src/accounts.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,9 @@ impl Accounts {
294294

295295
/// Performs a background fetch for all accounts in parallel.
296296
///
297-
/// If you need a timeout, then use [Accounts::background_fetch_with_timeout] instead.
298-
///
299-
/// The `AccountsBackgroundFetchDone` event is emitted at the end,
300-
/// process all events until you get this one and you can safely return to the background
301-
/// without forgeting to create notifications caused by timing race conditions.
302-
pub async fn background_fetch(&self) {
297+
/// This is an auxiliary function and not part of public API.
298+
/// Use [Accounts::background_fetch] instead.
299+
async fn background_fetch_without_timeout(&self) {
303300
async fn background_fetch_and_log_error(account: Context) {
304301
if let Err(error) = account.background_fetch().await {
305302
warn!(account, "{error:#}");
@@ -313,19 +310,15 @@ impl Accounts {
313310
.map(background_fetch_and_log_error),
314311
)
315312
.await;
316-
317-
self.emit_event(EventType::AccountsBackgroundFetchDone);
318313
}
319314

320315
/// Performs a background fetch for all accounts in parallel with a timeout.
321316
///
322-
/// If you want no timeout, then use [Accounts::background_fetch] instead.
323-
///
324317
/// The `AccountsBackgroundFetchDone` event is emitted at the end,
325318
/// process all events until you get this one and you can safely return to the background
326319
/// without forgeting to create notifications caused by timing race conditions.
327-
pub async fn background_fetch_with_timeout(&self, timeout: std::time::Duration) -> Result<()> {
328-
let result = tokio::time::timeout(timeout, self.background_fetch()).await;
320+
pub async fn background_fetch(&self, timeout: std::time::Duration) -> Result<()> {
321+
let result = tokio::time::timeout(timeout, self.background_fetch_without_timeout()).await;
329322
self.emit_event(EventType::AccountsBackgroundFetchDone);
330323
result.map_err(|err| err.into())
331324
}

0 commit comments

Comments
 (0)