Skip to content

Disable sparse writes when appending and test - #2145

Merged
oferchen merged 1 commit into
masterfrom
implement-rsync-3.4.1-parity-in-rust
Nov 14, 2025
Merged

oferchen merged 1 commit into
masterfrom
implement-rsync-3.4.1-parity-in-rust

Conversation

@oferchen

@oferchen oferchen commented Nov 14, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • disable sparse output when append or append-verify is requested so existing data is not converted to holes
  • extend the sparse transfer CLI tests to cover append and append-verify combinations

Testing

  • cargo test -p cli transfer_request_with_sparse_tests

[Codex Task](

@oferchen
oferchen merged commit 931ca7e into master Nov 14, 2025
@oferchen
oferchen deleted the implement-rsync-3.4.1-parity-in-rust branch November 14, 2025 11:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 127 to 134
// 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

oferchen added a commit that referenced this pull request May 14, 2026
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
oferchen added a commit that referenced this pull request May 18, 2026
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
oferchen added a commit that referenced this pull request May 18, 2026
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
oferchen added a commit that referenced this pull request Aug 24, 2026
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
oferchen added a commit that referenced this pull request Aug 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant