Repository navigation
fix(receiver): remove a non-regular obstacle before a file transfer - #7602
Merged
Merged
Conversation
A directory standing where the receiver has to create a symlink, FIFO, socket, or device node was neither removed nor reported. oc backed it up when `--backup` was on, tried a `File`-only unlink when it was off, discarded the result either way, and routed the failure to a verbosity-gated `debug_log!`. Upstream decides this in one place. `atomic_create` sets `dir_in_the_way` (generator.c:2469), which also forces `skip_atomic`, so a directory obstacle reaches `delete_item` whether or not `--backup` is set - the `make_backup` arm is unreachable for it in either mode. `delete_item` splits the same way one level down: the `rmdir` arm at delete.c:222-226, the `make_backup`/`unlink` arm in the `else` at delete.c:227-238. That is why the removal and the reporting are one change. A guard added to the backup path could only cover the `--backup`-on half; the four `--backup`-off shapes below would still be decided in links.rs and special.rs. And the reporting alone is a regression: with the removal disabled but the diagnostics in place, a symlink over an EMPTY directory exits 23 with `delete_file: unlink(obstacle) failed` where 3.5.0 exits 0. Measured by mutation, not argued. The five `backup_existing_before_replace` call sites in links.rs and special.rs now share one `make_way_for_replacement`, which owns both arms and emits upstream's diagnostics itself. Measured against rsync 3.5.0 (protocol 32) over a real `--server` child on both ends, `--backup` off: src kind | obstacle | 3.5.0 | oc before ---------|---------------|----------------------|--------------------- symlink | empty dir | 0, symlink placed | 12, dir kept symlink | non-empty dir | 23 + two diagnostics | 12, dir kept fifo | empty dir | 0, fifo placed | 0 SILENT, dir kept fifo | non-empty dir | 23 + two diagnostics | 0 SILENT, dir kept The failing rows also abandoned the rest of the batch: the sibling file upstream transfers at exit 23 was never written. Both FIFO rows reported success while losing the node - silent data loss, not a loud failure. All four now match 3.5.0 in exit code and in text. Under `--backup` with a sibling backup dir, oc RENAMED the directory into the backup area, which upstream never does: a wrong-data outcome at exit 0 that no exit-code assertion could catch. It is now removed. The full 3.5.0 python suite (345 cells, nonroot) reports exactly the six failures the expect manifest already names, so no row moves in either direction and the manifest is unchanged. Known residual, measured and out of scope: generator.c:2481 sets `DEL_RECURSE` under `--delete`/`--force`, so upstream removes a POPULATED directory obstacle recursively and exits 0. `--force` is parsed and discarded by the server arg parser (cli/src/frontend/server/flags.rs:615) and has no field in `ParsedServerFlags`, so the receiver cannot see it. Wiring it is a server-arg change. The refusal here is still closer to upstream than the pre-change abort at 12.
The EACCES cross-site note opened with a line-initial dash, so rustdoc - and `clippy::doc_lazy_continuation` under `-D warnings` - read it as a list item whose two following lines are lazy continuations. That is a hard error on the required fmt + clippy gate, raised twice at munge_symlinks.rs:124-125. Prose only, and the claim is unchanged: one fail-loud regression per site is still sufficient because both sites share the same upstream-parity rule (`PermissionDenied` is the only non-fatal class). No behaviour, no test, no manifest row moves. `cargo clippy --workspace --all-targets --all-features -- -D warnings` is clean with only this hunk applied, and no other file on this branch carries the same dash-then-continuation shape. A file no `mod` declaration reaches is never compiled, so it cannot raise this lint either - unlike a formatting diff, there is no invisible second site.
oferchen
force-pushed
the
fix/obstacle-regular-file-removal
branch
from
September 1, 2026 11:05
d01dcb6 to
47380fc
Compare
`create_specials` is the only constructor of `MakeWayFor::Device` and
`MakeWayFor::Special`, and it is `#[cfg(unix)]` - Windows has no `mknod`
path. On Windows both variants are therefore unconstructible, and
`dead_code` fires:
error: variants `Device` and `Special` are never constructed
--> crates/transfer/src/receiver/directory/obstacle.rs:81:5
= note: `-D dead-code` implied by `-D warnings`
ci.yml sets `RUSTFLAGS: "-D warnings"` at workflow scope, and the
`windows-test` job runs `cargo nextest run --locked -p transfer
--all-features`, so this is a hard failure of a required cell rather
than a warning.
Reproduced and fixed against a cross-check:
`RUSTFLAGS="-D warnings" cargo check -p transfer --all-targets
--all-features --target x86_64-pc-windows-gnu` errors before and is
clean after. `Symlink` stays ungated - the Windows symlink creator
constructs it.
Upstream removes whatever stands at the destination before it requests
the delta for a regular file:
generator.c:2147-2152
if (statret == 0 && !(stype == FT_REG || (write_devices && stype == FT_DEVICE))) {
if (delete_item(fname, sx.st.st_mode, del_opts | DEL_FOR_FILE) != 0)
goto cleanup;
statret = -1;
stat_errno = ENOENT;
}
oc had no analogue at that site, so the obstacle survived into the
commit. A rename over a symlink, FIFO, or socket replaces the node by
accident, which is why the plain-mode cells for those shapes looked
correct; a rename onto a directory is EISDIR, and there the whole run
stopped.
Measured against rsync 3.5.0 (protocol 32) over a real --server child on
both ends, source a regular file, obstacle at dst/a, each cell carrying a
control that proved the removal was permitted:
obstacle | 3.5.0 | oc before
--------------|----------------------------------------|-------------------
empty dir | 0, `<f+++++++++`, regular file placed | 12 `server error:
| | Is a directory
| | (21)`, dir kept
non-empty dir | 23 + `could not make way for new | 12, dir kept
| regular file: a` + `cannot delete |
| non-empty directory: a` |
Both oc rows also abandoned the batch: the sibling file upstream
transfers was never written.
This is a routing change, not a second mechanism. The previous commit's
`make_way_for_replacement` already owns both of `delete_item`'s arms -
rmdir with the ENOTEMPTY refusal for a directory, backup-if-`--backup`
else unlink for anything else - and already emits `could not make way for
%s %s`. The regular-file site now calls it with a new `DEL_FOR_FILE`
noun; no removal and no diagnostic is written twice.
The gate is upstream's own test: a destination is kept only when it is
already a regular file, or when `--write-devices` asked for the delta to
go straight into an existing device node. On success `dest_meta` is
cleared, which is `statret = -1`: 3.5.0 itemizes a cleared obstacle
`<f+++++++++`, not as a replacement of the node it displaced.
Proofs, all on the receiver path over a real --server child:
- routing disabled -> both rows redden at 12 with the same
`Is a directory (os error 21)` text measured above;
- `dest_meta = None` dropped -> the empty-dir cell reddens on the
itemize row alone (`<f.sT......` for `<f+++++++++`);
- the gate widened one type, so an ordinary regular destination is
unlinked too -> the no-obstacle companion reddens. Bytes alone do not
catch that, since -I re-sends the file either way; the `-i` row does.
Residual, unchanged and out of scope: a destination symlink whose target
is a regular file is still classified by the candidate pass's follow-stat
and so is renamed over rather than removed, so `--backup` does not see
it. `--force`/DEL_RECURSE stays unreachable while the server arg parser
discards `--force` (cli/src/frontend/server/flags.rs:615).
No row moves in any expect manifest.
oferchen
force-pushed
the
fix/obstacle-regular-file-removal
branch
from
September 1, 2026 11:13
47380fc to
3f4e5e1
Compare
This was referenced Sep 1, 2026
oferchen
added a commit
that referenced
this pull request
Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60 most recently merged pull requests, 44 were absent; of the most recent 45, 43 were absent. Nothing from #7574 onward was recorded at all. Each entry is derived from what the pull request actually landed - the merge commit and the body - not from its title. Three cases where those differ: * #7616 ships far more than the doc-alias correction its body describes: the `upstream_version` pin moves to 3.5.0 and `--version` starts naming `quic`, `sd-notify`, `vmsplice` and `send_zc`. * #7618 also adds the pull-request rustdoc-link job its body says was filed separately, which is what closes the master-only-gate recurrence. * #7602's squash carries the closed #7597 as its first commit, so the directory-obstacle half is recorded under #7602. #7587 is deliberately not recorded. Its merge commit is empty: the change had already landed as #7563, which the section already names. Entries extend the existing Keep a Changelog groups and the bold sub-groupings. Clusters that are one story carry one entry with several references: the FERROR_XFER routing and its two-phase drain (#7576, #7581), the connection-FSM close edge and the accept loop that outlives a session error (#7579, #7590), the three detaching daemon suites (#7578, #7588, #7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615, #7620). Only `## [Unreleased]` is touched; every released section, including the 3.4.4 statements that were correct when written, is byte-identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7597
⚠ This branch is stacked on #7597 (
fix/obstacle-dir-removal), not onmaster. Stack:1faf3c46f->0dac95a43(#7597) -> this PR. #7597 must land first. It createdmake_way_for_replacement, which owns both ofdelete_item()'s arms — this PR only routes a sixth call site onto it.The gap
Upstream removes whatever stands at the destination before it requests the delta for a regular file:
oc had no analogue at that site, so the obstacle survived into the commit. A
rename()over a symlink, FIFO, or socket replaces the node by accident — which is why the plain-mode cells for those shapes looked correct — butrename()onto a directory isEISDIR, and there the whole run stopped.Measured
rsync 3.5.0 (protocol 32) over a real
--serverchild on both ends, source a regular file, obstacle atdst/a, sibling file present, each cell carrying a control that proved the removal was permitted (removablein all cells, so a surviving node means not attempted, never attempted and refused):rc=0,<f+++++++++ a, regular file placedrc=12server error: Is a directory (os error 21), dir kept, sibling unsentrc=0,<f+++++++++ a, regular file placedrc=23,could not make way for new regular file: a+cannot delete non-empty directory: a, dir keptrc=12, same abortrc=23, both lines, dir kept, sibling writtenBoth
beforerows were re-measured on this branch's parent, not quoted from an earlier report. The four symlink/FIFO rows #7597 fixed are unchanged, and the full six-shape sweep (symlink, fifo, regular x empty, non-empty) now matches 3.5.0 in exit code, itemize row, and diagnostic text.What changed
A routing change, not a second mechanism.
make_way_for_replacementalready owns thermdir-with-ENOTEMPTY-refusal arm and the backup-else-unlink arm, and already emitscould not make way for %s %s. The regular-file site now calls it with a newDEL_FOR_FILEnoun ("regular file",delete.c:276). No removal and no diagnostic is written twice.The gate is upstream's own test: a destination is kept only when it is already a regular file, or when
--write-devicesasked for the delta to go straight into an existing device node. On successdest_metais cleared, which isstatret = -1: 3.5.0 itemizes a cleared obstacle<f+++++++++, not as a replacement of the node it displaced.Proofs
Three independent mutations, each killing exactly one cell:
Is a directory (os error 21)text verbatim;dest_meta = Nonedropped -> the empty-dir cell reddens on the itemize row alone (<f.sT......where 3.5.0 prints<f+++++++++);-Ire-sends the file either way, so a delete-then-create still lands the right content at exit 0); the-irow does. The companion was inert against this mutation until it asserted on the row, which is why it now does.Manifests
No row moves. The 3.5.0 python suite, all 345 cells, nonroot, against this branch's binary: 8
FAIL, of which 6 are exactly the rowstools/ci/upstream-3.5.0-expect.nonroot.txtalready names. The other two (daemon-copylinks-parent-escape,daemon-scan-cwd-desync) pass 3/3 when re-run in isolation against the same binary — host contention inside the 25-cell chunk, not a moved row. No manifest is edited.Residuals, unchanged and out of scope
stat, so they are renamed over rather than removed and--backupdoes not see them. Neither can reach the new branch (dest_metaisSome(is_file)/Nonerespectively), so this PR leaves both exactly as they were. Measured: the dangling-symlink-under---backupcell is the one row in that sweep where oc still differs from 3.5.0.--force/DEL_RECURSEstays unreachable while the server arg parser discards--force(cli/src/frontend/server/flags.rs:615).