serve webdav: set the modtime on the destination of COPY and MOVE - #9915
Open
thanadon-dev wants to merge 1 commit into
Open
serve webdav: set the modtime on the destination of COPY and MOVE#9915thanadon-dev wants to merge 1 commit into
thanadon-dev wants to merge 1 commit into
Conversation
The X-OC-Mtime header names the modification time the client wants the resource to end up with. For COPY and MOVE that resource is the one named in the Destination header, but postprocess looked the request URL up instead. For MOVE the source is gone by then, so the lookup failed and the server logged "Failed to stat node: file does not exist" after an otherwise successful move, with the modtime never applied. For COPY the lookup succeeded and the modtime was written to the source file, silently leaving both files wrong. Resolve the Destination header to a remote for COPY and MOVE, stripping --baseurl when one is set, and read X-OC-Mtime first so requests without the header do no work at all. Fixes rclone#8725
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.
The problem
postprocessapplies theX-OC-Mtimeheader by looking up the request URL, but forCOPYandMOVEthe resource the client is describing is the one named in theDestinationheader.For
MOVEthe source no longer exists by the timepostprocessruns, soVFS.Statfails and the server logs the error from #8725 after an otherwise successful move:The modtime is silently never applied.
COPYhas the same root cause with a worse outcome: the stat succeeds (the source is still there), so the requested modtime is written to the source file and the destination keeps the wrong one. No error is logged, so this has been failing quietly.The change
Destinationheader to a remote forCOPY/MOVE, stripping--baseurlwhen one is configured.PUTis unchanged.X-OC-Mtimeup front and return early when it is absent, so requests without the header no longer do a VFS lookup at all.Net behaviour change is limited to requests that actually carry
X-OC-Mtime.Testing
Added
TestCopyMoveSetsModTimeOnDestinationincmd/serve/webdav/webdav_test.go, coveringCOPYandMOVE, each with and without--baseurl(the prefix case exercises the stripping, since theDestinationheader carries the prefix but VFS paths do not).Verified RED → GREEN: with the fix reverted all four subtests fail; with the fix all four pass.
I also reproduced the original report locally before starting, with
rclone serve webdavplusrclone movetoagainst it, and confirmed the error no longer appears afterwards.Ran locally:
go test ./cmd/serve/webdav/(passes, 41s),go vet ./cmd/serve/webdav/,gofmt -lclean. I don't havegolangci-linton this machine, so that gate is down to CI.Fixes #8725