Skip to content

Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend - #2846

Merged
rfc2822 merged 2 commits into
mainfrom
localcollection-suspend-5
Aug 21, 2026
Merged

Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend#2846
rfc2822 merged 2 commits into
mainfrom
localcollection-suspend-5

Conversation

@rfc2822

@rfc2822 rfc2822 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Another step of #2828 (taking #2784 into account).

Purpose

Continues making at.bitfire.davdroid.resource.local (the Local* classes between SyncManager and the content providers) a proper suspending API.

Short description

  • Made LocalResource.updateSequence(), deleteLocal() and resetDeleted() suspend; each implementation wraps just its blocking ContentProvider call in a narrow withContext(Dispatchers.IO).
  • AndroidContact.delete()/AndroidGroup.delete() now wrap RemoteException as LocalStorageException, per Wrap all RemoteException-throwing calls with LocalStorageException #2784.
  • Adjusted LocalTestResource and ReadOnlyPolicyTest for the new suspend signatures.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@rfc2822 rfc2822 changed the title Make further LocalResource methods suspendable; wrap blocking calls… Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend; fix already-suspend Local* methods still blocking Aug 20, 2026
@rfc2822 rfc2822 changed the title Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend; fix already-suspend Local* methods still blocking Make further LocalResource methods suspend; fix already-suspend Local* methods still blocking Aug 20, 2026
@rfc2822 rfc2822 changed the title Make further LocalResource methods suspend; fix already-suspend Local* methods still blocking Make further LocalResource methods suspend Aug 20, 2026
@rfc2822 rfc2822 changed the title Make further LocalResource methods suspend Make LocalResource.updateSequence()/deleteLocal()/resetDeleted() suspend Aug 20, 2026
@rfc2822
rfc2822 requested a lite review from Copilot August 20, 2026 17:44
@rfc2822
rfc2822 marked this pull request as ready for review August 20, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(), and resetDeleted() suspending and updated implementations to use withContext(Dispatchers.IO).
  • Wrapped RemoteException as LocalStorageException in AndroidContact.delete() and AndroidGroup.delete().
  • Updated ReadOnlyPolicyTest and LocalTestResource to 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.

@ArnyminerZ ArnyminerZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rfc2822
rfc2822 merged commit 2534c16 into main Aug 21, 2026
13 checks passed
@rfc2822
rfc2822 deleted the localcollection-suspend-5 branch August 21, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants