Repository navigation
Disable sparse writes when appending and test - #2145
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".
| // Upstream rsync disables sparse writes whenever `--preallocate` is active | ||
| // because the preallocation request must materialise every range in the | ||
| // destination file. Keep the same behaviour by refusing to punch holes | ||
| // when preallocation is enabled. | ||
| let use_sparse_writes = context.sparse_enabled() && !context.preallocate_enabled(); | ||
| // destination file. It also turns off sparse handling for append modes so | ||
| // the receiver does not punch holes into the portion of the file that was | ||
| // already present. Mirror that behaviour here. | ||
| let use_sparse_writes = | ||
| context.sparse_enabled() && !context.preallocate_enabled() && !context.append_enabled(); | ||
| let partial_enabled = context.partial_enabled(); |
There was a problem hiding this comment.
Disable sparse only when append actually used
The new use_sparse_writes guard now unconditionally turns off sparse handling whenever the user passes --append, because it only checks context.append_enabled(). That means even when determine_append_mode() later decides that append is disabled (e.g. destination file is missing, zero-length, or fails verification) we still copy via the dense path and silently ignore --sparse. Previously, and in upstream rsync, a first-time transfer with --append --sparse created a sparse destination; after this change it always allocates the full file, wasting space and diverging from expected behaviour. Sparse writes should only be suppressed when we actually enter append mode (i.e. when AppendMode::Append is selected), not simply because the flag was requested.
Useful? React with 👍 / 👎.
Upstream rsync (options.c:2382) rejects the combination `--append --whole-file` with the message `--append cannot be used with --whole-file` and exits with RERR_SYNTAX (1). oc-rsync was silently accepting both flags together. Add the conflict check to both validation layers that gate config construction: - `ClientConfigBuilder::validate` (core) - the primary path used by the CLI; surfaces a `ConfigConflict` whose `Display` matches upstream wording. - `LocalCopyOptionsBuilder::validate` (engine) - keeps the engine-level builder in sync so programmatic embedders also reject the combination. Only an explicit `--whole-file` (`Some(true)`) conflicts; the default (`None`) and `--no-whole-file` (`Some(false)`) remain accepted so existing call sites that set the tri-state from auto-detection are unaffected. Tests cover the engine builder, the core config builder (including the exact upstream error string), and an end-to-end CLI integration test that drives `cli::run` and asserts the RERR_SYNTAX exit code plus the diagnostic mentions both flags. Refs: #2145, #2146, #2147
Upstream rsync (options.c:2382) rejects the combination `--append --whole-file` with the message `--append cannot be used with --whole-file` and exits with RERR_SYNTAX (1). oc-rsync was silently accepting both flags together. Add the conflict check to both validation layers that gate config construction: - `ClientConfigBuilder::validate` (core) - the primary path used by the CLI; surfaces a `ConfigConflict` whose `Display` matches upstream wording. - `LocalCopyOptionsBuilder::validate` (engine) - keeps the engine-level builder in sync so programmatic embedders also reject the combination. Only an explicit `--whole-file` (`Some(true)`) conflicts; the default (`None`) and `--no-whole-file` (`Some(false)`) remain accepted so existing call sites that set the tri-state from auto-detection are unaffected. Tests cover the engine builder, the core config builder (including the exact upstream error string), and an end-to-end CLI integration test that drives `cli::run` and asserts the RERR_SYNTAX exit code plus the diagnostic mentions both flags. Refs: #2145, #2146, #2147
Upstream rsync (options.c:2382) rejects the combination `--append --whole-file` with the message `--append cannot be used with --whole-file` and exits with RERR_SYNTAX (1). oc-rsync was silently accepting both flags together. Add the conflict check to both validation layers that gate config construction: - `ClientConfigBuilder::validate` (core) - the primary path used by the CLI; surfaces a `ConfigConflict` whose `Display` matches upstream wording. - `LocalCopyOptionsBuilder::validate` (engine) - keeps the engine-level builder in sync so programmatic embedders also reject the combination. Only an explicit `--whole-file` (`Some(true)`) conflicts; the default (`None`) and `--no-whole-file` (`Some(false)`) remain accepted so existing call sites that set the tri-state from auto-detection are unaffected. Tests cover the engine builder, the core config builder (including the exact upstream error string), and an end-to-end CLI integration test that drives `cli::run` and asserts the RERR_SYNTAX exit code plus the diagnostic mentions both flags. Refs: #2145, #2146, #2147
Upstream rsync (options.c:2382) rejects the combination `--append --whole-file` with the message `--append cannot be used with --whole-file` and exits with RERR_SYNTAX (1). oc-rsync was silently accepting both flags together. Add the conflict check to both validation layers that gate config construction: - `ClientConfigBuilder::validate` (core) - the primary path used by the CLI; surfaces a `ConfigConflict` whose `Display` matches upstream wording. - `LocalCopyOptionsBuilder::validate` (engine) - keeps the engine-level builder in sync so programmatic embedders also reject the combination. Only an explicit `--whole-file` (`Some(true)`) conflicts; the default (`None`) and `--no-whole-file` (`Some(false)`) remain accepted so existing call sites that set the tri-state from auto-detection are unaffected. Tests cover the engine builder, the core config builder (including the exact upstream error string), and an end-to-end CLI integration test that drives `cli::run` and asserts the RERR_SYNTAX exit code plus the diagnostic mentions both flags. Refs: #2145, #2146, #2147
Upstream rsync (options.c:2382) rejects the combination `--append --whole-file` with the message `--append cannot be used with --whole-file` and exits with RERR_SYNTAX (1). oc-rsync was silently accepting both flags together. Add the conflict check to both validation layers that gate config construction: - `ClientConfigBuilder::validate` (core) - the primary path used by the CLI; surfaces a `ConfigConflict` whose `Display` matches upstream wording. - `LocalCopyOptionsBuilder::validate` (engine) - keeps the engine-level builder in sync so programmatic embedders also reject the combination. Only an explicit `--whole-file` (`Some(true)`) conflicts; the default (`None`) and `--no-whole-file` (`Some(false)`) remain accepted so existing call sites that set the tri-state from auto-detection are unaffected. Tests cover the engine builder, the core config builder (including the exact upstream error string), and an end-to-end CLI integration test that drives `cli::run` and asserts the RERR_SYNTAX exit code plus the diagnostic mentions both flags. Refs: #2145, #2146, #2147
Summary
Testing
[Codex Task](