Thanks to visit codestin.com
Credit goes to github.com

Skip to content

serve webdav: set the modtime on the destination of COPY and MOVE - #9915

Open
thanadon-dev wants to merge 1 commit into
rclone:masterfrom
thanadon-dev:fix/issue-8725-webdav-mtime-destination
Open

serve webdav: set the modtime on the destination of COPY and MOVE#9915
thanadon-dev wants to merge 1 commit into
rclone:masterfrom
thanadon-dev:fix/issue-8725-webdav-mtime-destination

Conversation

@thanadon-dev

Copy link
Copy Markdown

The problem

postprocess applies the X-OC-Mtime header by looking up the request URL, but for COPY and MOVE the resource the client is describing is the one named in the Destination header.

For MOVE the source no longer exists by the time postprocess runs, so VFS.Stat fails and the server logs the error from #8725 after an otherwise successful move:

INFO  : file.ext: Moved (server-side) to: newfilename.txt
ERROR : Failed to stat node: file does not exist

The modtime is silently never applied.

COPY has 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

  • Resolve the Destination header to a remote for COPY/MOVE, stripping --baseurl when one is configured. PUT is unchanged.
  • Read X-OC-Mtime up 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 TestCopyMoveSetsModTimeOnDestination in cmd/serve/webdav/webdav_test.go, covering COPY and MOVE, each with and without --baseurl (the prefix case exercises the stripping, since the Destination header 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.

--- FAIL: TestCopyMoveSetsModTimeOnDestination/COPY
--- FAIL: TestCopyMoveSetsModTimeOnDestination/MOVE
--- FAIL: TestCopyMoveSetsModTimeOnDestination/COPY/prefix
--- FAIL: TestCopyMoveSetsModTimeOnDestination/MOVE/prefix
--- PASS: TestCopyMoveSetsModTimeOnDestination/COPY
--- PASS: TestCopyMoveSetsModTimeOnDestination/MOVE
--- PASS: TestCopyMoveSetsModTimeOnDestination/COPY/prefix
--- PASS: TestCopyMoveSetsModTimeOnDestination/MOVE/prefix

I also reproduced the original report locally before starting, with rclone serve webdav plus rclone moveto against it, and confirmed the error no longer appears afterwards.

Ran locally: go test ./cmd/serve/webdav/ (passes, 41s), go vet ./cmd/serve/webdav/, gofmt -l clean. I don't have golangci-lint on this machine, so that gate is down to CI.

Fixes #8725

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rclone serve webdav: Server logs Failed to stat node error after a successful moveto operation

1 participant