Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend - #2846
Merged
Conversation
LocalResource methods suspendable; wrap blocking calls…LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend; fix already-suspend Local* methods still blocking
LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend; fix already-suspend Local* methods still blockingLocalResource methods suspend; fix already-suspend Local* methods still blocking
LocalResource methods suspend; fix already-suspend Local* methods still blockingLocalResource methods suspend
LocalResource methods suspendLocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend
rfc2822
marked this pull request as ready for review
August 20, 2026 17:44
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the migration of at.bitfire.davdroid.resource.local toward a suspending, non-blocking API by making LocalResource.updateSequence() / deleteLocal() / resetDeleted() suspend and wrapping the underlying blocking ContentProvider interactions in withContext(Dispatchers.IO). It also advances #2784 by wrapping RemoteException in LocalStorageException for contact/group deletion, and updates tests to use coroutine-aware MockK verification.
Changes:
- Made
LocalResource.updateSequence(),deleteLocal(), andresetDeleted()suspending and updated implementations to usewithContext(Dispatchers.IO). - Wrapped
RemoteExceptionasLocalStorageExceptioninAndroidContact.delete()andAndroidGroup.delete(). - Updated
ReadOnlyPolicyTestandLocalTestResourceto reflect new suspend signatures.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| synctools/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidGroup.kt | Wraps provider delete in try/catch(RemoteException) and throws LocalStorageException. |
| synctools/src/main/kotlin/at/bitfire/synctools/storage/contacts/AndroidContact.kt | Wraps provider delete in try/catch(RemoteException) and throws LocalStorageException. |
| core/src/test/kotlin/at/bitfire/davdroid/sync/ReadOnlyPolicyTest.kt | Uses coVerify for the now-suspending resetDeleted() calls. |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalTask.kt | Makes sequence update / deletion methods suspending and dispatches blocking calls to Dispatchers.IO. |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalResource.kt | Updates interface contract: updateSequence() / deleteLocal() / resetDeleted() become suspend. |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalJtxObject.kt | Wraps sequence update / delete / reset-deleted calls in withContext(Dispatchers.IO). |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalGroup.kt | Makes delete/resetDeleted suspending and dispatches provider work to Dispatchers.IO. |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalEvent.kt | Makes sequence update / delete / resetDeleted suspending and dispatches provider work to Dispatchers.IO. |
| core/src/main/kotlin/at/bitfire/davdroid/resource/local/LocalContact.kt | Makes delete/resetDeleted suspending and dispatches provider work to Dispatchers.IO. |
| core/src/androidTest/kotlin/at/bitfire/davdroid/sync/LocalTestResource.kt | Updates test resource to match new suspend signatures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another step of #2828 (taking #2784 into account).
Purpose
Continues making
at.bitfire.davdroid.resource.local(theLocal*classes betweenSyncManagerand the content providers) a proper suspending API.Short description
LocalResource.updateSequence(),deleteLocal()andresetDeleted()suspend; each implementation wraps just its blockingContentProvidercall in a narrowwithContext(Dispatchers.IO).AndroidContact.delete()/AndroidGroup.delete()now wrapRemoteExceptionasLocalStorageException, per Wrap allRemoteException-throwing calls withLocalStorageException#2784.LocalTestResourceandReadOnlyPolicyTestfor the new suspend signatures.Checklist