rsyncopts: accept and honor --whole-file/-W#59
Closed
tenox7 wants to merge 1 commit into
Closed
Conversation
Prior to this change, the gokrazy client option table had --whole-file,
-W, --no-whole-file, and --no-W commented out, so passing -W to
rsyncclient.New / rsynccmd.Command failed with "unknown option". Even when
the underlying field was set programmatically, two downstream sites still
ignored it:
* ServerOptions did not append W to argstr, so the remote daemon never
learned the client wanted whole-file mode.
* The receiver generator unconditionally generated and sent rolling
checksums against any existing local file, instead of short-circuiting
to requestFullFile when -W is set.
This commit:
* Uncomments the three client-side flag entries in gokrazyTable.
* Adds an Options.WholeFile accessor.
* Plumbs WholeFile through to receiver.TransferOpts and consults it in
recvGenerator before opening the local file for sum generation.
* Emits W in ServerOptions so the daemon sees the flag.
Without these, even after the parser change, a CLI invocation with
"rsync -W rsync://daemon/module/file /local/" against an existing partial
would still fall through the slow delta-sync path; pulls were also slow
because the daemon never received -W and could not skip its own work.
f58b3e1 to
c4fbd58
Compare
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
The gokrazy fork parses but never acts on
-W. This PR plumbs it end-to-end so callers (rsyncclient.New,rsynccmd.Command) can ask for whole-file mode and have it actually take effect on the wire and in the receiver.Three coordinated changes:
internal/rsyncopts/rsyncopts.go: uncomments the--whole-file/-W/--no-whole-file/--no-Wentries ingokrazyTable()so the client side actually accepts these flags. Adds anOptions.WholeFile()accessor.internal/rsyncopts/serveroptions.go: emitsWin argstr whenwhole_file > 0, so the remote daemon learns the client is asking for whole-file mode.internal/receiver/{generator,transfer}.go: plumbsWholeFilethroughTransferOptsand consults it inrecvGeneratorto short-circuit torequestFullFile()instead of generating rolling checksums against an existing local file. Wires the field at bothinternal/maincmd/clientmaincmd.goandrsyncd/rsyncd.goconstruction sites.Why
Without this, even after enabling the parser,
-Whad no observable effect. A pull against an existing partial would still walk the slow delta-sync path because the receiver kept generating sums; pushes were also stuck on the slow path because the daemon never received-Wand could not skip its own work.Test plan
go build ./...cleango test ./...pass (full suite, includinginternal/rsyncopts,rsyncclient,internal/maincmd, integration tests)rsynccmd.Command(\"rsync\", \"-W\", ...)failed with-W: unknown option; after, parses and propagates to wire.