Skip to content

fix: discard a file whose partial-dir cannot be created, like upstream - #8290

Merged
oferchen merged 2 commits into
fix/local-copy-open-per-filefrom
fix/partial-dir-create-discard
Nov 3, 2026
Merged

oferchen merged 2 commits into
fix/local-copy-open-per-filefrom
fix/partial-dir-create-discard

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

When a receiver cannot create the staging directory a completed file moves into under --delay-updates, it now behaves like rsync 3.5.1:

  • It prints Unable to create partial-dir for <file> -- discarding completed file.
  • It removes the temp and carries on with the next file.
  • The exit code is unchanged, so with no other errors the run exits 0.

This covers both --delay-updates' implicit .~tmp~ and an explicit relative or absolute --partial-dir. Before this change, both receivers aborted the whole run on the first file:

  • a local copy exited 23 with failed to create partial dir '...';
  • a push exited 3 with server error: Permission denied.

upstream: receiver.c:1318-1325. A failed handle_partial_dir(partialptr, PDIR_CREATE) is rprintf(FERROR, ...), do_unlink_at(fnametmp) and recv_ok = -1. Plain FERROR never sets got_xfer_error.

Stacked on #8285, and reuses its shared commit classifier.

Changes

  • engine::commit_failure:
    • New CommitOp::PartialDir. Its operand is the staging dir; its destination is the file's final path.
    • New CommitDisposition::Discard: print a plain FERROR line, drop the file, and don't count it as a transfer error.
    • failure_line renders upstream's wording, naming the file by its transfer name.
  • Network receiver:
    • disk_commit/process/commit.rs tags the obstruction clear and the staging-dir create.
    • absorb_commit_error sends the line as MessageCode::Error, not ErrorXfer, and does not count a skipped file.
  • Local engine:
    • stage_into_partial_dir tags its create.
    • LocalCopyError::report_skipped_commit becomes report_commit_failure<T: Default>() -> Result<T, Self>. A discarded file resolves to Ok(T::default()), so the walk carries on with no error.

Oracle (tarball 3.5.1, /home/ofer/up351/rsync-3.5.1/rsync, Linux, non-root)

Fixture: src/a src/b with a writable --temp-dir and --delay-updates. The staging parent is 0555 for the run: dst, or apd for the absolute case.

transport .~tmp~ --partial-dir=.pd --partial-dir=<abs>/x
local identical identical identical
push (rsh --server receiver) identical identical identical
pull (client receiver) identical identical identical

Every cell matches 3.5.1:

  • the same two stderr lines and nothing else;
  • exit 0;
  • no file landed;
  • the temp dir is empty.

Not changed (stated, not hidden)

These differences only appear under -v, and none comes from this change:

  • Line order. oc prints the per-file lines and the -v names in a different order from upstream. That is the existing per-file warning-position work (tasks 379 and 382) and the decided local listing order.
  • Push byte counts. oc's push received total counts the two error lines, because oc's server sends them as MSG frames. 3.5.1's server writes them to stderr. This affects every server-side error line, not just this one. Raised separately.
  • Failed transfers with --partial. The recv_ok == 0 arm ("discarding partial file", where a failed transfer is kept in the partial dir) is not reachable deterministically from a fixture and is not wired here. oc's per-file failure path does not stage into the partial dir.

Tests

  • tests/partial_dir_create_failure_discards.rs: 3 staging shapes x 3 transports. Each asserts the full stderr, exit 0, no file landed and an empty temp dir.
  • Unit tests:
    • a_partial_dir_failure_discards_without_a_transfer_error.
    • The PartialDir line in failure_line_mirrors_each_upstream_rsyserr.
    • The Discard arm in report_commit_failure_marks_only_per_file_commit_failures_reported.
  • Mutations, one per arm, each killed:
    • Engine tag dropped: the 3 e2e tests fail.
    • Network tag dropped: the 3 e2e tests fail.
    • Discard changed to SkipFile: 2 unit tests and the 3 e2e tests fail.
    • Network line sent as ErrorXfer: the 3 e2e tests fail.
    • Engine Discard turned into a reported error: the unit test and the 3 e2e tests fail.

oferchen added a commit that referenced this pull request Oct 29, 2026
@github-actions github-actions Bot added the bug Something isn't working label Oct 29, 2026
A receiver that could not create the --delay-updates / --partial-dir
staging directory for a completed file aborted the whole run (exit 23
on a local copy, exit 3 on a push). rsync 3.5.1 prints "Unable to
create partial-dir for %s -- discarding completed file.", unlinks the
temp and moves on (receiver.c:1318-1325); the line is a plain FERROR,
so the exit code is unchanged.

Tag the staging-dir create with CommitOp::PartialDir in both receivers
and classify it as the new CommitDisposition::Discard: the network
receiver sends the line as MSG_ERROR without counting a skipped file,
and the local engine reports it and resolves the entry to success.
@oferchen
oferchen force-pushed the fix/local-copy-open-per-file branch from 6990bf9 to 91250da Compare November 3, 2026 07:24
@oferchen
oferchen force-pushed the fix/partial-dir-create-discard branch from ddddaf2 to d376f20 Compare November 3, 2026 07:31
@oferchen
oferchen merged commit dfe30ff into fix/local-copy-open-per-file Nov 3, 2026
8 of 48 checks passed
@oferchen
oferchen deleted the fix/partial-dir-create-discard branch November 3, 2026 09:36
oferchen added a commit that referenced this pull request Nov 3, 2026
…, as upstream (#8284)

* fix: skip receiver open and rename failures per file like upstream

The pipelined receiver skipped a file only when its output failed with
PermissionDenied; any other errno (ENOSPC, EROFS, EISDIR, and the ENOENT
an --inplace open reports after its no-create retry) aborted the run.
Upstream decides by the failed operation: a temp create, in-place open
or rename into place is an FERROR_XFER line and the transfer goes on to
exit 23 (receiver.c:465-468, receiver.c:1242-1261, rsync.c:918-927),
while a failed backup or close is RERR_FILEIO. The split now lives in
one classifier keyed on the CommitOp tag each raising site attaches.

In-place and device opens are tagged Open and print upstream's
"open %s failed" line, and a temp create under a missing parent keeps
its Mkstemp tag and real errno. A missing --inplace destination is
created 0600 until its final mode is applied (receiver.c:1221-1226).

* docs: fill CHANGELOG PR number for #8284

* fix: report a failed cross-device copy fallback as upstream copy line

robust_rename() falls back to copying when the rename crosses devices.
Upstream reports a failed copy as "copy %s -> \"%s\"" (rsync.c:919-921,
ret == -2) and moves on to the next file. The copy failure is now tagged
CommitOp::Copy, which the per-file classifier skips and the receiver
renders with the copy verb; an inner stage tag survives the rename tag
the caller wraps around it.

* fix: skip local-copy temp, open and rename failures per file

A local copy that could not create its temp file, open an --inplace
destination or rename a file into place aborted after the first file
with its own wording, and a missing --inplace target was reported as
vanished (exit 24). rsync 3.5.1 prints the receiver line for each file
(receiver.c:465-468, receiver.c:1242-1261, rsync.c:918-927) and ends
with exit 23.

Move the commit-op tag and CommitDisposition classifier into engine so
the network receiver and the local engine share one decision and one
wording (CommitOp::failure_line). The engine tags its mkstemp, open,
rename and copy sites, reports skip-file failures at the per-operand
and per-entry sites, and counts NotFound as vanished only when it is
untagged. The oc-only Direct write retries a failed create once through
the named temp path, so the reported failure is upstream mkstemp one.

* docs: fill CHANGELOG PR number for #8285

* fix: discard a file whose partial-dir cannot be created, like upstream

A receiver that could not create the --delay-updates / --partial-dir
staging directory for a completed file aborted the whole run (exit 23
on a local copy, exit 3 on a push). rsync 3.5.1 prints "Unable to
create partial-dir for %s -- discarding completed file.", unlinks the
temp and moves on (receiver.c:1318-1325); the line is a plain FERROR,
so the exit code is unchanged.

Tag the staging-dir create with CommitOp::PartialDir in both receivers
and classify it as the new CommitDisposition::Discard: the network
receiver sends the line as MSG_ERROR without counting a skipped file,
and the local engine reports it and resolves the entry to success.

* docs: fill CHANGELOG PR number for #8290

* fix: let a failed macOS clone fall through to the per-file temp path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant