Skip to content

fix: report receiver hard-link, attribute and deletion-skip errors as upstream does - #8318

Merged
oferchen merged 1 commit into
masterfrom
fix/receiver-error-accounting
Nov 4, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/receiver-error-accounting

Conversation

@oferchen

@oferchen oferchen commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Summary

This PR fixes three places where the network receiver reports or counts an error differently from rsync 3.5.1. It covers tasks 216, 218 and 251. Every cell was measured against the 3.5.1 tarball build, on both push and pull.

Case rsync 3.5.1 oc before oc after
-RH --no-implied-dirs, follower under a regular file dst/sub exit 23, [generator] link "<dst>/sub/b" => a failed: Not a directory (20) exit 11, the transfer aborts same as 3.5.1
-aH, empty directory where a follower goes exit 0, the link replaces the directory exit 3, the transfer aborts same as 3.5.1
-a --inplace into a root-owned 0666 file exit 23, [receiver] chgrp "<dst>/f" failed: Operation not permitted (1) exit 23, failed to preserve group '<dst>/f': ... (os error 1) same as 3.5.1
--delete with a sender I/O error, --info=nonreg0 prints IO error encountered -- skipping file deletion prints nothing on pull or local same as 3.5.1 (push, pull, local)
same, with -q prints nothing prints nothing prints nothing

Changes

Hard links (task 216)

Every failed hard link is now an error for that one file, whatever the errno: it prints link %s => %s failed, the run goes on, and it ends with exit 23. Before, only EACCES/EPERM were handled per file. Every other errno aborted the transfer.

  • upstream: hlink.c:475-489 hard_link_one(). rsyserr(FERROR_XFER, errno, "link %s => %s failed", full_fname(fname), oldname) is at :486.

An existing destination where a follower goes is now cleared the same way as for symlinks and devices: make_way_for_replacement(..., MakeWayFor::File). An empty directory is removed, a populated one is refused, and anything else is backed up or unlinked. Before, the code tried a silent unlink, and the link then failed with EEXIST and aborted the transfer.

  • upstream: hlink.c:224-256 maybe_hard_link()
  • upstream: generator.c:2464-2483 atomic_create(..., DEL_FOR_FILE)
  • upstream: delete.c:179, delete.c:283

Receiver attribute failures (task 218)

When the receiver fails to set an attribute on the file it just wrote, the error now uses upstream's wording: chown|chgrp %s failed, failed to set times on %s or failed to set permissions on %s. It names the file that was handed to set_file_attrs() (the temp file before the rename) through full_fname(). The disk thread formats the line with the same path context as the receiver's other diagnostics; FullFnamePaths::receiver is now shared by the disk-commit config and the pipelined receiver. The exit code was already 23 and does not change.

  • upstream: rsync.c:911/937 finish_transfer() -> set_file_attrs(fnametmp, ...)
  • upstream: rsync.c:685 ("%s %s failed"), :784 (times), :815 (permissions)

Skipped-deletion notice (task 251)

IO error encountered -- skipping file deletion is now a level-0 info event on the client receiver and in the local copy. No --info setting hides it; only --quiet does. Before, it was gated on NONREG level 1.

  • upstream: generator.c:304-311 delete_in_dir() prints it with a plain rprintf(FINFO, ...), at :308.
  • upstream: log.c:344-345, where rwrite()'s FINFO arm returns under quiet.

Deviations

  • Populated directory where a hard-link follower goes. rsync 3.5.1 prints cannot delete non-empty directory: b (delete.c:179) and could not make way for new regular file: b (delete.c:283), then hangs until it is killed. I measured this on push and pull. oc prints the same two lines, skips the follower and ends with exit 23. The deviation is documented at the call site in receiver/directory/links.rs and pinned by populated_directory_in_the_way_of_a_hard_link_is_refused_without_hanging. That cell has no upstream oracle; the CLI runner's wall-time limit is its hang guard.

Known limits

  • Task 525: 3.5.1's atomic_create() links a follower under a temp name and then renames it over an existing destination. oc unlinks first and then links, as it already does for symlinks and devices. So for an existing regular file in an unwritable directory, 3.5.1 reports link "<dst>/.b.XXXXXX" => ... while oc reports delete_file: unlink(b) failed.
  • Task 524: on a --delete push or pull where the sender hits an I/O error, 3.5.1 still deletes the extraneous file in a directory it swept before the error (the INC_RECURSE root sweep). oc keeps it. The new notice test asserts only the notice and the exit code.

Tests

  • tests/receiver_generator_rsyserr.rs gets six new cells:
    • hard_link_under_a_file_parent_is_reported_and_exits_23
    • empty_directory_in_the_way_of_a_hard_link_is_replaced
    • populated_directory_in_the_way_of_a_hard_link_is_refused_without_hanging
    • failed_receiver_set_file_attrs_uses_upstream_wording (sudo-planted root-owned file; skipped as root or without sudo -n)
    • io_error_delete_notice_is_a_plain_finfo (push, pull and local, each at default, --info=nonreg0 and -q)
    • The harness gains Direction::Local and a run_output method that also returns stdout.
  • receiver/tests/hard_links.rs: create_hardlinks_surfaces_non_eacces_error asserted the old abort-on-EEXIST behaviour, and its upstream claim does not match 3.5.1. It is replaced by create_hardlinks_replaces_an_empty_directory_obstacle and create_hardlinks_reports_a_refused_obstacle_and_continues.
  • engine/.../execute_ignore_errors.rs: the notice filter now matches the level-0 Misc event.

Results on the host:

  • tests/receiver_generator_rsyserr.rs: 8/8 passed.
  • Targeted transfer + engine + metadata (filter io_error|delete|hard|link|metadata|full_fname|notice|skip|attrs): 1959/1959 passed.
  • Mutations (one per arm; each one turns exactly its own cell red, 7/8 pass):
    • Abort again on any non-EACCES link errno: hard_link_under_a_file_parent_is_reported_and_exits_23 fails.
    • Go back to a plain unlink before the link: empty_directory_in_the_way_of_a_hard_link_is_replaced fails.
    • Drop the upstream attribute wording: failed_receiver_set_file_attrs_uses_upstream_wording fails.
    • Put the notice back on NONREG level 1: io_error_delete_notice_is_a_plain_finfo fails.
  • cargo fmt --all --check, tools/ci/check_rustfmt_all.py, cargo clippy --workspace --all-targets --all-features -D warnings and the same clippy run for x86_64-pc-windows-gnu: all pass.

…ream

- hard links: every failed link() is a per-file "link %s => %s failed"
  with exit 23 (hlink.c hard_link_one), and an obstacle at the follower
  path goes through the shared make-way path (generator.c atomic_create)
- receiver set_file_attrs failures use upstream's chown/chgrp/times/
  permissions wording through full_fname (rsync.c:685, :784, :815)
- "IO error encountered -- skipping file deletion" is a plain FINFO,
  hidden only by --quiet (generator.c:308, log.c:344-345)
@github-actions github-actions Bot added the bug Something isn't working label Nov 3, 2026
@oferchen oferchen closed this Nov 4, 2026
@oferchen oferchen reopened this Nov 4, 2026
@oferchen
oferchen merged commit 69be724 into master Nov 4, 2026
76 of 127 checks passed
@oferchen
oferchen deleted the fix/receiver-error-accounting branch November 4, 2026 04:53
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