Can't rename files in `rclone serve webdav` with `--baseurl`: maybe wrong handling of "MOVE" request method

What is the problem you are having with rclone?

Can't rename files (including directories) in WebDAV server of rclone serve webdav, if --baseurl is specified.

I tested this in Windows (putting \\localhost@8080\test in explorer's location bar) and Mac (mount_webdav command), and both failed in renaming files.

This is probably caused by wrong handling of "MOVE" requests invoked on renaming. The "destination" field of a "MOVE" request header contain the baseurl, which should be cut off.

I learned this in writing some kind of WebDAV proxy for myself. The error is exactly same as I encountered then.

Run the command 'rclone version' and share the full output of the command.

confirmed in three versions:

rclone v1.65.2
- os/version: Microsoft Windows 11 Home 22H2 (64 bit)
- os/kernel: 10.0.22621.3155 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.21.6
- go/linking: static
- go/tags: cmount
rclone v1.61.1
- os/version: Microsoft Windows 11 Home 22H2 (64 bit)
- os/kernel: 10.0.22621.3155 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.19.4
- go/linking: static
- go/tags: cmount
rclone v1.65.1
- os/version: darwin 13.5.2 (64 bit)
- os/kernel: 22.6.0 (x86_64)
- os/type: darwin
- os/arch: amd64
- go/version: go1.21.5
- go/linking: dynamic
- go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

local (but should happen in all storage type)

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone serve webdav . --baseurl test

The rclone config contents with secrets removed.

N/A

A log from the command with the -vv flag

I tried to rename testdir/testfile to testdir/testfile2 .

2024/02/15 22:11:39 INFO  : test/testdir/testfile: MOVE from 127.0.0.1:54799
2024/02/15 22:11:40 DEBUG : /testdir: OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : /testdir: >OpenFile: fd=testdir/ (r), err=<nil>
2024/02/15 22:11:40 DEBUG : /testdir: OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : /testdir: >OpenFile: fd=testdir/ (r), err=<nil>
2024/02/15 22:11:40 INFO  : test/testdir: PROPFIND from 127.0.0.1:54800
2024/02/15 22:11:40 DEBUG : /testdir: OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : /testdir: >OpenFile: fd=testdir/ (r), err=<nil>
2024/02/15 22:11:40 DEBUG : /testdir: OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : /testdir: >OpenFile: fd=testdir/ (r), err=<nil>
2024/02/15 22:11:40 INFO  : test/testdir: PROPFIND from 127.0.0.1:54801
2024/02/15 22:11:40 DEBUG : : OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : : >OpenFile: fd=/ (r), err=<nil>
2024/02/15 22:11:40 DEBUG : : OpenFile: flags=O_RDONLY, perm=----------
2024/02/15 22:11:40 DEBUG : : >OpenFile: fd=/ (r), err=<nil>
2024/02/15 22:11:40 INFO  : test: PROPFIND from 127.0.0.1:54802

It looks like stuff is definitely broken when using --baseurl with rclone serve webdav

mkdir /tmp/src
echo hello > /tmp/src/file1.txt
rclone serve webdav -vv --baseurl test /tmp/src/

Then trying it with rclone

rclone lsf --webdav-url "http://127.0.0.1:8080/test/" -vv --dump bodies :webdav:

Gives the error

2024/02/20 10:15:01 ERROR : test/file1.txt: Entry doesn't belong in directory "" (contains subdir) - ignoring
test/

The XML response looks like this

<D:href>test/file1.txt</D:href>

Which is surely wrong - the href should be relative to the baseurl if it doesn't start with a /. Without a / it is referring to http://127.0.0.1:8080/test/test/file1.txt

If you use --baseurl /test I think you'll find it will work. However this is not what the docs say, so I've prepared a small fix - can you give this a go?

v1.66.0-beta.7686.31727bf43.fix-webdav-prefix on branch fix-webdav-prefix (uploaded in 15-30 mins)

1 Like

Thank you!
Using --baseurl /test instead worked perfectly (successful renaming) with existing versions, but your hotfix seems not working correctly on explorer.exe Webdav client. It even fails with basic file browsing (not only renaming). It seems working in web browser.

Great

Can you try this one instead? I made a mistake with the previous one and based it off an old commit

v1.66.0-beta.7705.d354f2eab.fix-webdav-prefix on branch fix-webdav-prefix (uploaded in 15-30 mins)

Thanks

Thanks for your prompt update.
Hmm, to me, the new version still doesn't work well on Windows...
Also, I confirmed the two versions both works perfectly with --baseurl /test. Only --baseurl test seems to be broken.

I see what happened there! Can you give this a go please?

v1.66.0-beta.7706.7f5e90294.fix-webdav-prefix on branch fix-webdav-prefix (uploaded in 15-30 mins)

Thank you!

1 Like

Oh this works perfectly! Thank you very much!!

Thanks for testing :slight_smile:

I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.66

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.