Repository navigation
Implement --update parity for local copies - #904
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if context.update_enabled() { | ||
| if let Some(existing) = destination_state.as_ref() { | ||
| if destination_is_newer(metadata, existing) { | ||
| context.summary_mut().record_regular_file_skipped_newer(); | ||
| context.record(LocalCopyRecord::new( | ||
| record_path.clone(), | ||
| LocalCopyAction::SkippedNewerDestination, | ||
| 0, | ||
| Duration::default(), | ||
| Some(LocalCopyMetadata::from_metadata(metadata)), | ||
| )); | ||
| return Ok(()); | ||
| } |
There was a problem hiding this comment.
Apply
--update only to regular destination files
The new --update handling skips a copy whenever the destination entry has a newer mtime, but it does so before verifying that the existing entry is the same kind of object as the source. If a regular file is copied over a newer symbolic link, device, or other non-regular entry, these blocks short‑circuit and leave the differing destination untouched. Upstream rsync still replaces non‑matching types even when --update is set, so the current logic will silently keep stale symlinks or devices whenever they happen to have a newer timestamp. Consider checking existing.file_type().is_file() (or otherwise ensuring the types match) before honoring --update; only identical file types should be skipped due to the flag.
Useful? React with 👍 / 👎.
| if context.update_enabled() { | ||
| if let Some(existing) = existing_metadata.as_ref() { | ||
| if destination_is_newer(metadata, existing) { | ||
| context.summary_mut().record_regular_file_skipped_newer(); | ||
| context.hard_links.record(metadata, destination); | ||
| context.record(LocalCopyRecord::new( | ||
| record_path.clone(), | ||
| LocalCopyAction::SkippedNewerDestination, | ||
| 0, | ||
| Duration::default(), | ||
| Some(LocalCopyMetadata::from_metadata(metadata)), | ||
| )); | ||
| return Ok(()); |
There was a problem hiding this comment.
Apply
--update only to regular destination files
The same unconditional --update skip appears in the non–dry run path. If the destination is a symlink or other non-regular entry that is newer than the source, the new block returns early and never replaces it, even though rsync would normally overwrite type mismatches regardless of timestamps. This can leave a different object in place when --update is supplied. Guard the destination_is_newer check with a type comparison so that only regular files (or matching types) are skipped.
Useful? React with 👍 / 👎.
Summary
--update/-uto the CLI help, parser, and supported options list so the flag can be requesteddocs/feature_matrix.mdTesting
Red → Green count: n/a (no goldens affected)