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`.
This commit is contained in:
parent
0506d44989
commit
e8a69a3222
|
|
@ -724,19 +724,20 @@ async fn execute_action(
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e.into()),
|
||||||
};
|
};
|
||||||
let checksum = compute_checksum(&data);
|
let checksum = compute_checksum(&data);
|
||||||
|
let len = data.len() as u64;
|
||||||
|
|
||||||
if let Some(parent) = path_parent(path) {
|
if let Some(parent) = path_parent(path) {
|
||||||
client.ensure_dir(parent).await?;
|
client.ensure_dir(parent).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
report(&format!(" ^ Uploading {}", path));
|
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
|
// Record in sync state using local file metadata
|
||||||
let modified = std::fs::metadata(&local_path).ok()
|
let modified = std::fs::metadata(&local_path).ok()
|
||||||
.and_then(|m| m.modified().ok())
|
.and_then(|m| m.modified().ok())
|
||||||
.map(|t| { let dt: DateTime<Utc> = t.into(); dt.to_rfc3339() });
|
.map(|t| { let dt: DateTime<Utc> = 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 } => {
|
SyncAction::Conflict { path } => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue