Skip to content

[PB-6477]: migrate DocumentsProvider IO to kotlinx coroutines#482

Open
terrerox wants to merge 2 commits into
feature/PB-6282-Signal-Android-RNfrom
fix/PB-6477-upload-download-coroutines
Open

[PB-6477]: migrate DocumentsProvider IO to kotlinx coroutines#482
terrerox wants to merge 2 commits into
feature/PB-6282-Signal-Android-RNfrom
fix/PB-6477-upload-download-coroutines

Conversation

@terrerox

@terrerox terrerox commented Jun 6, 2026

Copy link
Copy Markdown

Replace CompletableFuture.get(), Call.execute() and the manual AtomicReference + setOnCancelListener cancellation plumbing with kotlinx-coroutines across the native DocumentsProvider stack: crypto, download and upload now suspend via Call.await()/CallAwait and CryptoServiceAwait, and openDocument bridges to coroutines through runBlockingIo (BlockingIo) instead of a plain runBlocking, surfacing cancellation as FileNotFoundException. Adds kotlinx-coroutines-android and kotlinx-coroutines-test to android/app/build.gradle and JVM unit tests for BlockingIo, CryptoServiceAwait, EncryptedFileDownloader and EncryptedFileUploader.

Replace CompletableFuture.get(), Call.execute() and the manual
AtomicReference + setOnCancelListener cancellation plumbing with
kotlinx-coroutines across the native DocumentsProvider stack:
crypto, download and upload now suspend via Call.await()/CallAwait and
CryptoServiceAwait, and openDocument bridges to coroutines through
runBlockingIo (BlockingIo) instead of a plain runBlocking, surfacing
cancellation as FileNotFoundException. Adds kotlinx-coroutines-android
and kotlinx-coroutines-test to android/app/build.gradle and JVM unit
tests for BlockingIo, CryptoServiceAwait, EncryptedFileDownloader and
EncryptedFileUploader.

NOTE: a separate, unrelated change by the maintainer lives in the same
file (InternxtDocumentsProvider.kt) and could not be split out because
interactive staging (git add -p) is unavailable and editing source is
out of scope for the git-manager: refresh() now triggers a background
revalidateChildren (new revalidate/fetchAllRows helpers and the
FolderLoad.isRevalidating flag) instead of invalidateChildren. It is
bundled here intentionally; see progress/git_android_coroutines_migration.md.

Refs: PB-6282
@terrerox terrerox requested a review from TamaraFinogina as a code owner June 6, 2026 21:57
@terrerox terrerox requested a review from CandelR June 6, 2026 21:58
@terrerox terrerox self-assigned this Jun 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jun 6, 2026

Copy link
Copy Markdown

is FileNotFoundException -> e
is OperationCanceledException ->
FileNotFoundException("openDocument $id cancelled").apply { initCause(e) }
is CancellationException -> e

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.

Use isCancellation(...)

@xabg2

xabg2 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Also, check the Unit tests @terrerox

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.

2 participants