File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -3157,15 +3157,14 @@ void dc_accounts_maybe_network_lost (dc_accounts_t* accounts);
3157
3157
*
3158
3158
* dc_accounts_background_fetch() was created for the iOS Background fetch.
3159
3159
*
3160
- * The `DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE` event is emitted at the end,
3161
- * process all events until you get this one and you can safely return to the background
3160
+ * The `DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE` event is emitted at the end
3161
+ * even in case of timeout, unless the function fails and returns 0.
3162
+ * Process all events until you get this one and you can safely return to the background
3162
3163
* without forgetting to create notifications caused by timing race conditions.
3163
3164
*
3164
3165
* @memberof dc_accounts_t
3165
3166
* @param timeout The timeout in seconds
3166
- * @return Return 1 on success and 0 on failure (like timeout)
3167
- * But note that this only indicates that the fetch of all accounts was done before the timeout.
3168
- * To know whether it worked you need to look for the events.
3167
+ * @return Return 1 if DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE was emitted and 0 otherwise.
3169
3168
*/
3170
3169
int dc_accounts_background_fetch (dc_accounts_t * accounts , uint64_t timeout );
3171
3170
Original file line number Diff line number Diff line change @@ -233,8 +233,9 @@ impl CommandApi {
233
233
234
234
/// Performs a background fetch for all accounts in parallel with a timeout.
235
235
///
236
- /// The `AccountsBackgroundFetchDone` event is emitted at the end,
237
- /// process all events until you get this one and you can safely return to the background
236
+ /// The `AccountsBackgroundFetchDone` event is emitted at the end
237
+ /// if the method returns sucessfully, even in case of timeout.
238
+ /// Process all events until you get this one and you can safely return to the background
238
239
/// without forgetting to create notifications caused by timing race conditions.
239
240
async fn accounts_background_fetch ( & self , timeout_in_seconds : f64 ) -> Result < ( ) > {
240
241
self . accounts
Original file line number Diff line number Diff line change @@ -317,10 +317,18 @@ impl Accounts {
317
317
/// The `AccountsBackgroundFetchDone` event is emitted at the end,
318
318
/// process all events until you get this one and you can safely return to the background
319
319
/// without forgetting to create notifications caused by timing race conditions.
320
+ ///
321
+ /// On error no `AccountsBackgroundFetchDone` event is emitted.
320
322
pub async fn background_fetch ( & self , timeout : std:: time:: Duration ) -> Result < ( ) > {
321
- let result = tokio:: time:: timeout ( timeout, self . background_fetch_without_timeout ( ) ) . await ;
323
+ if let Err ( _err) =
324
+ tokio:: time:: timeout ( timeout, self . background_fetch_without_timeout ( ) ) . await
325
+ {
326
+ self . emit_event ( EventType :: Warning (
327
+ "Background fetch timed out." . to_string ( ) ,
328
+ ) ) ;
329
+ }
322
330
self . emit_event ( EventType :: AccountsBackgroundFetchDone ) ;
323
- result . map_err ( |err| err . into ( ) )
331
+ Ok ( ( ) )
324
332
}
325
333
326
334
/// Emits a single event.
You can’t perform that action at this time.
0 commit comments