From e8a69a3222ba3f46f2bed97c6b76e19b943cfdac Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Apr 2026 07:22:01 +0000 Subject: [PATCH] perf(sync): avoid cloning upload payload `SyncAction::Upload` cloned the file bytes solely so it could later read `data.len()` for the sync-state record. Capture the length up front and move the buffer into `put_file`. --- crates/onyx-core/src/sync.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/onyx-core/src/sync.rs b/crates/onyx-core/src/sync.rs index c97f0c6..6bb626d 100644 --- a/crates/onyx-core/src/sync.rs +++ b/crates/onyx-core/src/sync.rs @@ -724,19 +724,20 @@ async fn execute_action( Err(e) => return Err(e.into()), }; let checksum = compute_checksum(&data); + let len = data.len() as u64; if let Some(parent) = path_parent(path) { client.ensure_dir(parent).await?; } report(&format!(" ^ Uploading {}", path)); - client.put_file(path, data.clone()).await?; + client.put_file(path, data).await?; // Record in sync state using local file metadata let modified = std::fs::metadata(&local_path).ok() .and_then(|m| m.modified().ok()) .map(|t| { let dt: DateTime = t.into(); dt.to_rfc3339() }); - sync_state.record_file(path, &checksum, modified.as_deref(), data.len() as u64); + sync_state.record_file(path, &checksum, modified.as_deref(), len); } SyncAction::Conflict { path } => {