Skip to content

feat: support concurrent chunk uploads#126

Merged
TorstenDittmann merged 2 commits into
mainfrom
concurrent-chunk-uploads-1-9-x-minimal
May 21, 2026
Merged

feat: support concurrent chunk uploads#126
TorstenDittmann merged 2 commits into
mainfrom
concurrent-chunk-uploads-1-9-x-minimal

Conversation

@TorstenDittmann
Copy link
Copy Markdown
Contributor

This PR updates the SDK to support concurrent chunk uploads.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 21, 2026

Greptile Summary

This PR refactors chunkedUpload in Client.kt to upload up to 8 chunks simultaneously using Kotlin's coroutineScope/async, replacing the previous sequential loop. Atomic types (AtomicInteger, AtomicLong, AtomicReference) and a synchronized block guard shared progress state across concurrent workers.

  • The sequential first-chunk dispatch is preserved to establish the upload session ID before concurrent workers start; remaining chunks are distributed via AtomicInteger.getAndIncrement across the worker pool.
  • Progress tracking accumulates byte counts and completed-chunk counts atomically, and the onProgress callback is serialised behind a lock.
  • The SDK version is bumped from 24.1.1 to 24.2.0 to reflect the new capability.

Confidence Score: 4/5

The concurrent upload machinery is well-structured, but the shared mutable state coordination across the new worker pool warrants a careful second look before merging.

The core concurrency plumbing (atomic progress counters, synchronized progress callback, AtomicReference for results) is sound. The two concerns flagged—dead-code index == 0 branch and the possibility of completedResultRef remaining null on a distributed Appwrite backend—are both non-blocking in practice but indicate the completion-result selection logic needs a little hardening.

library/src/main/java/io/appwrite/Client.kt — specifically the chunks.isNotEmpty() concurrent block and the uploadChunk inner function.

Important Files Changed

Filename Overview
library/src/main/java/io/appwrite/Client.kt Rewrites chunkedUpload to dispatch up to 8 concurrent chunk workers using coroutineScope/async; adds AtomicInteger/AtomicLong/AtomicReference for progress tracking and a synchronized block for onProgress serialization; introduces a local readChunk helper opening a new RandomAccessFile per chunk. The completion-result selection falls back to lastResultRef when completedResultRef is unset, and a dead index == 0 branch inside uploadChunk could mislead future maintainers.

Reviews (2): Last reviewed commit: "feat: support concurrent chunk uploads" | Re-trigger Greptile

Comment thread library/src/main/java/io/appwrite/Client.kt
Comment thread library/src/main/java/io/appwrite/Client.kt
Comment thread library/src/main/java/io/appwrite/Client.kt Outdated
Comment thread library/src/main/java/io/appwrite/Client.kt
@TorstenDittmann TorstenDittmann merged commit 9fc700d into main May 21, 2026
1 check passed
@TorstenDittmann TorstenDittmann deleted the concurrent-chunk-uploads-1-9-x-minimal branch May 21, 2026 17:51
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