Repository navigation
refactor: share one change_dir#N formatter across receivers - #8902
Merged
Merged
Conversation
The change_dir#N line that get_local_name() prints (main.c:779, :837, :866, :982) was written in three places: the transfer receiver's SelectStep Display, the core local-copy error mapping and the engine DestinationEntryFailed message. All three now render through logging::ChangeDirFailed, so the text has one source. ChangeDirStep has the three steps a caller can reach. change_dir#4 (main.c:1214) has no caller and gets no variant. Callers keep their own name rules (trailing slash, full_fname) and map their step enums onto ChangeDirStep; DestinationEntry::number() becomes change_dir_step(). User-visible output is unchanged.
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
rsync 3.5.2 prints one line when the receiver cannot enter its destination:
rsyserr(FERROR, errno, "change_dir#N %s failed", full_fname(..))inget_local_name():change_dir#1(main.c:779): an existing destination directorychange_dir#2(main.c:837): a destination directory the run createdchange_dir#3(main.c:866, main.c:982): the parent of a single-file destinationrsyserr()appends: <strerror> (<errno>)(log.c:575-585).oc wrote this text in three places:
transferreceiver/dest_root.rs: theSelectStepDisplay (push and pull receivers)coreclient/error.rs: the local-copy error mappingenginelocal_copy/error.rs: theDestinationEntryFailedmessageAll three now render through one formatter,
logging::ChangeDirFailed.loggingis the only crate all three already depend on (transferdoesnot depend on
engine).Design
logging::ChangeDirStep { One, Two, Three }.change_dir#4(main.c:1214) has no caller in oc, so it gets no variant.
logging::ChangeDirFailed::new(step, fname, cause)renderschange_dir#N <fname> failed: <upstream_errno_text>. Thersync: [role]prefix stays with the caller, as before.
fnamearrives already rendered byfull_fname(). Each caller keeps itsown name rules:
change_dir#1keeps the operand's trailing slash(main.c:779 prints
dest_pathas given);change_dir#2lops it(main.c:810).
ChangeDirStep.engine::DestinationEntry::number()becomeschange_dir_step().Output
User-visible text is unchanged. The core and transfer lines were already
byte-for-byte upstream's, and the call sites now produce the same bytes
through the shared formatter. Engine's
DestinationEntryFailedDisplay isnot printed to users (core's
map_local_copy_errorbuilds the user-visibleline); it now uses
full_fname()like the other two, not"{path}".Oracle cells for #8890 (local copy) and #8899 (network receivers), run on
master and on this branch, with
OC_RSYNC_UPSTREAM_BIN_3_5_2set to rsync3.5.2 and
OC_RSYNC_UPSTREAM_COMPAT=1so 3.5.2 is required:core --test untrusted_destination_symlinkcli --test receiver_preflight_refusals --test mkpath_through_a_regular_filebin --test destination_root_owner_walk(root via sudo)transfer --lib test(dest_root)core --lib test(change_dir) | test(destination_entry)engine --lib test(change_dir) | test(destination_entry)The same 44 cells by name, all passing, before and after.
Tests
New
loggingunit table (change_dir.rs)::837, :866), with
%sfilled in and thersyserr()tail appended.read_dir, so the tail is theplatform's own strerror text, not a string the test writes.
Mutations, each restored afterwards:
change_dir #N(space added)faileddroppedA mutation in the shared formatter turns the core and bin cells red, so both
the local-copy path and the network receivers go through it.
Verification
cargo fmt --all -- --check,tools/ci/check_rustfmt_all.py: cleancargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings: cleanx86_64-pc-windows-gnu: cleanRUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-deps --locked: cleancargo run --locked -p xtask -- no-placeholders: OKpython3 tools/ci/citation_drift_audit.py --ratchet: OK