api: add APIs to stop background fetch

New APIs are JSON-RPC method stop_background_fetch(),
Rust method Accounts.stop_background_fetch()
and C method dc_accounts_stop_background_fetch().

These APIs allow to cancel background fetch early
even before the initially set timeout,
for example on Android when the system calls
`Service.onTimeout()` for a `dataSync` foreground service.
This commit is contained in:
link2xt
2025-11-13 04:09:12 +00:00
committed by l
parent cd50c263e8
commit 1c4d2dd78e
4 changed files with 110 additions and 2 deletions

View File

@@ -283,6 +283,11 @@ impl CommandApi {
Ok(())
}
async fn stop_background_fetch(&self) -> Result<()> {
self.accounts.read().await.stop_background_fetch();
Ok(())
}
// ---------------------------------------------
// Methods that work on individual accounts
// ---------------------------------------------