Repository navigation
fix: keep local-copy output and exit codes in line with upstream - #8222
Merged
Merged
Conversation
A local copy that processed every entry but owed a non-zero exit code returned an error and the CLI dropped its summary, so an exit-23 run printed no itemize rows, names or --stats block. The engine now attaches the completed report to that error and the CLI renders it before the trailer; only an aborted run has no output. The exit code is decided once, after the run, in upstream's order (cleanup.c:210-218): DEL_LIMIT, then VANISHED, then GENERAL or got_xfer_error, so 23 outranks 24 outranks 25. A --max-delete cap only counts the refusal (delete.c:217-219) and never stops the transfer; under --delete-before it used to abort before anything was copied. The run-wide skipped total is reported once (generator.c:2904-2907) and the exit-25 trailer names "the --max-delete limit stopped deletions" (log.c:100). The "max deletions reached" line, which upstream never prints, is gone. The "IO error encountered -- skipping file deletion" notice is printed only by a sweep that would still delete (generator.c:304-311), not by a --delete-before or --delete-during run's post-transfer step.
Clearing a directory obstacle for an incoming file peeled its children with an unbounded walk that deleted straight into a mounted filesystem under --one-file-system. The peel now takes the device-aware leaf walk whenever -x (or --max-delete) is in force, as the delete passes do: a child on another device pins the obstacle, the make-room fails with exit 23, and the mount keeps every file (delete.c:141-149, flist.c:1715). A nested mount point is a DEBUG_GTE(DEL, 1) note (delete.c:144-149); only a top-level one prints "cannot delete mount point" (generator.c:336-340).
The delete limit is now a run-wide skipped-deletes counter, so nothing classifies a LocalCopyError as the limit any more.
24 of 27 tasks
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.
Summary
--statstotals before the exit trailer. Before, the CLI dropped the whole summary.--max-deletecap only counts refusals and never stops the transfer; under--delete-beforeit used to abort before anything was copied.--one-file-system, clearing a directory obstacle for an incoming file keeps a mount point inside it, instead of deleting into the mounted filesystem.Details
Output on a non-zero exit. The engine returned
Err(partial_transfer)at the end of a run that had processed every entry, and the CLI'sErrarm discarded the summary.LocalCopyErrornow carries the completedLocalCopyReport, whichcoreturns into theClientSummary.execute_transferrenders it through the same path as a clean run, then prints the trailer. An aborted run still has no report. upstream:cleanup.c:210-218mapsio_error/got_xfer_errorto the exit code only after the transfer and its output are complete.Exit precedence and the delete cap.
recursive/mod.rsdeferred it per directory, with comments claiming "25 outranks 23/24", the reverse ofcleanup.c:210-218. It also aborted the remaining sources, and under--delete-beforethe whole transfer. The cap is now a run-wideskipped_deletescounter (delete.c:217-219), the deferral machinery is gone, andcompleted_run_exit_error()applies upstream's order once.Deletions stopped due to --max-delete limit (N skipped)(generator.c:2904-2907). The exit-25 trailer namesthe --max-delete limit stopped deletions(log.c:100).max deletions reached, skipping N remainingline has no upstream counterpart and is removed.Skip notice.
IO error encountered -- skipping file deletionis printed only by a sweep that would still delete (generator.c:304-311). A--delete-beforeor--delete-duringrun's post-transfer step no longer prints it.-xmake-room.peel_or_probenow takes the device-aware leaf walk whenever-xor--max-deleteis in force, as the delete passes already did. A child on another device pins the obstacle, the make-room fails (23), and the mount keeps its files (delete.c:141-149,flist.c:1715).DEBUG_GTE(DEL, 1)note (delete.c:144-149). Only a top-level one printscannot delete mount point(generator.c:336-340).Oracle, against
/usr/bin/rsync3.5.1 on Linux. Fixture:src/{a,sub/z}with an unreadablesrc/unread, anddst/{stale1,stale2,sub/stale3}.-ri>f+++++++++rows-r --stats-rv --delete-before --max-delete=1(2 skipped)(2 skipped)-rv --delete --max-delete=1, no failure-rv --force -x, tmpfs inside the obstacle-rv --delete -x,--max-delete=100,-rvvKnown gaps, not in this PR:
rsync error: failed to copy file ...trailer, where upstream printsrsync: [sender] send_files failed to open "...": ... (13)followed by the genericsome files/attrs were not transferredtrailer.--delete,--delete-delay). Upstream's sender reportsio_erroronly after its send loop (sender.c:808-809), so those decisions never see it, and upstream deletessub/stale3/stale2where oc keeps them. Exit codes match; the deleted set differs. A vanished file also sets oc's gate, although upstream gates only onIOERR_GENERAL.--statscounters. Created and transferred counts and sent/received bytes still differ from upstream on a run with an unreadable file.EBUSYwithout-x. AnEBUSYrmdir of a mount reached without-xstill aborts the local run. Upstream logsdelete_file: rmdir(...) failedand continues.Test plan
tests/local_copy_exit_fidelity.rs, four cases;one_file_system_make_room_keeps_a_mount_inside_the_obstacleincrates/engine/src/local_copy/tests/execute_one_file_system.rs.-xpeel;cargo nextest run -p engine -p core -p cli -p bin --all-features: 12804 passed, 128 skipped.cargo fmt --all -- --checkandpython3 tools/ci/check_rustfmt_all.py.cargo clippy -p engine -p core -p cli -p bin --all-targets --all-features --no-deps -- -D warnings.cargo check -p engine -p core -p cli --all-features --target x86_64-pc-windows-gnu.python3 tools/ci/unsafe_owner_deps.py,cargo run -p xtask -- no-placeholders,cargo run -p xtask -- citations.The unreadable-file tests skip with a
SKIP:line when the process can read a mode-0 file, i.e. when running as root. Repro:cargo nextest run -p bin --all-features -E 'binary(local_copy_exit_fidelity)'.Coordination
Conventional commit prefix
fix:Security considerations
--one-file-system, and--max-deleteenforcement.delete.c:141-149,delete.c:217-219,cleanup.c:210-218.Pre-merge checklist
cargo fmt --allrun locally.CHANGELOG.mdupdated if user-visible.SECURITY.mdupdated if security-relevant.