Expand description
Streaming download implementation.
§Protocol
- Acquire a scoped resource lock via
LockRegistry. - Emit
transfer:state { state: running }. - Issue
GetObject— obtaincontent_lengthand the bodyByteStream. - Open
<dest>.partialfor writing (atomic rename on success). - Stream 256 KB chunks; for each chunk: write to file, increment
transferred_bytes, callemit_progress(throttled). - Poll the cancel receiver between chunks.
- On cancel: delete
.partial, emitCanceled, release lock withCancel. - On success: rename
.partial→ final, emitDone, release lock. - On I/O or S3 error: delete
.partial, emitFailed, release lock.
§OCP contract
The atomic .partial rename pattern and lock acquire/release sequence are
reusable for any downloaded asset. Upload (task 32) acquires the same lock
registry with a different op_name.
Constants§
- CHUNK_
SIZE 🔒 - Bytes per read chunk — 256 KB.
Functions§
- cleanup_
on_ 🔒error - Error path: delete
.partial(if any), emit Failed, release lock. - download_
object - Stream-download
keyfrombucketand write it atomically todest_path. - handle_
cancel 🔒 - Cancel path: delete
.partial, emit Canceled, release lock. - now_ms 🔒
- now_
secs 🔒