Prefer VersionStore::store_version_from_reader#405
Conversation
…producer task errors out--otherwise we may attempt to begin or continue uploads after sending abort_multipart_upload, which would be weird
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR removes the synchronous path-based Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…ror that didn't originate from the aws sdk
…t multipart upload shenanigans
…3 without multipart upload shenanigans" because it fails at runtime without a size This reverts commit 7690d04.
…ge in the direct streaming attempt
…t; use file size to determine part size for multipart uploads for files > 100MB
e689414 to
16d3337
Compare
510937a to
816bdf6
Compare
1ac0ab1 to
58091e1
Compare
792882a to
a7c773f
Compare
Co-authored-by: Malcolm Greaves <malcolmgreaves@users.noreply.github.com>
…ires updating some dependencies
6cc41e0 to
f2c6737
Compare
…in favor of using VersionStore::store_version_from_reader
a7c773f to
20dd721
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/lib/src/api/client/entries.rs (1)
242-249: Consider streaming from disk instead of re-buffering in memory.The current implementation reads the entire file into memory with
tokio::fs::read, computes the hash, then passes the same bytes viaCursortostore_version_from_reader. For large files, this keeps the full content in memory.Since the hash computation requires the full content, the memory usage isn't a regression from before. However, for consistency with other call sites and better memory efficiency on large files, consider refactoring to:
- Compute hash during download (streaming hash)
- Then stream from disk to version store using
tokio::fs::File+BufReaderThis would avoid holding the full file in memory after hashing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/lib/src/api/client/entries.rs` around lines 242 - 249, The code currently reads the whole file into memory via tokio::fs::read, computes the hash with util::hasher::hash_buffer and then constructs a Cursor to call version_store.store_version_from_reader, which keeps the full buffer in memory; change this to compute the hash while streaming (e.g., open the file with tokio::fs::File and feed bytes through a streaming hasher during download or read), then reopen or seek the file and pass a tokio::fs::File wrapped in tokio::io::BufReader (or an async Read) into version_store.store_version_from_reader along with the computed hash and size so the full content is not re-buffered in memory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/lib/src/api/client/entries.rs`:
- Around line 242-249: The code currently reads the whole file into memory via
tokio::fs::read, computes the hash with util::hasher::hash_buffer and then
constructs a Cursor to call version_store.store_version_from_reader, which keeps
the full buffer in memory; change this to compute the hash while streaming
(e.g., open the file with tokio::fs::File and feed bytes through a streaming
hasher during download or read), then reopen or seek the file and pass a
tokio::fs::File wrapped in tokio::io::BufReader (or an async Read) into
version_store.store_version_from_reader along with the computed hash and size so
the full content is not re-buffered in memory.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6bd41b51-0e02-40c9-8f84-314469b879ad
📒 Files selected for processing (10)
.claude/CLAUDE.mdTODO.mdcrates/lib/src/api/client/entries.rscrates/lib/src/core/v_latest/add.rscrates/lib/src/core/v_latest/branches.rscrates/lib/src/core/v_latest/workspaces/files.rscrates/lib/src/repositories/remote_mode/checkout.rscrates/lib/src/storage/local.rscrates/lib/src/storage/s3.rscrates/lib/src/storage/version_store.rs
💤 Files with no reviewable changes (3)
- crates/lib/src/storage/local.rs
- crates/lib/src/storage/s3.rs
- crates/lib/src/storage/version_store.rs
This PR removes
VersionStore::store_version_from_path(and its implementations) in favor of usingVersionStore::store_version_from_reader. This makes it more straightforward to maintain theVersionStoretrait and its various implementations, and makes it clearer how file bytes are traveling through the various calls.