1
mirror of https://github.com/rclone/rclone synced 2024-12-27 19:43:48 +01:00

webdav: fix Copy, Move and DirMove to be more compatible

The fix was to use an absolute URL in the Destination: as per RFC2518

This makes it compatible with the golang.org/x/net/webdav server
This commit is contained in:
Nick Craig-Wood 2017-10-25 22:56:47 +01:00
parent fd2406f94e
commit e612673ea0

View File

@ -638,13 +638,17 @@ func (f *Fs) copyOrMove(src fs.Object, remote string, method string) (fs.Object,
if err != nil { if err != nil {
return nil, errors.Wrap(err, "Copy mkParentDir failed") return nil, errors.Wrap(err, "Copy mkParentDir failed")
} }
destinationURL, err := rest.URLJoin(f.endpoint, dstPath)
if err != nil {
return nil, errors.Wrap(err, "copyOrMove couldn't join URL")
}
var resp *http.Response var resp *http.Response
opts := rest.Opts{ opts := rest.Opts{
Method: method, Method: method,
Path: srcObj.filePath(), Path: srcObj.filePath(),
NoResponse: true, NoResponse: true,
ExtraHeaders: map[string]string{ ExtraHeaders: map[string]string{
"Destination": path.Join(f.endpoint.Path, dstPath), "Destination": destinationURL.String(),
"Overwrite": "F", "Overwrite": "F",
}, },
} }
@ -732,13 +736,18 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
return errors.Wrap(err, "DirMove mkParentDir dst failed") return errors.Wrap(err, "DirMove mkParentDir dst failed")
} }
destinationURL, err := rest.URLJoin(f.endpoint, dstPath)
if err != nil {
return errors.Wrap(err, "DirMove couldn't join URL")
}
var resp *http.Response var resp *http.Response
opts := rest.Opts{ opts := rest.Opts{
Method: "MOVE", Method: "MOVE",
Path: addSlash(srcPath), Path: addSlash(srcPath),
NoResponse: true, NoResponse: true,
ExtraHeaders: map[string]string{ ExtraHeaders: map[string]string{
"Destination": addSlash(path.Join(f.endpoint.Path, dstPath)), "Destination": addSlash(destinationURL.String()),
"Overwrite": "F", "Overwrite": "F",
}, },
} }