From e612673ea0e7a2df8d1fb43d8eb0fdf945b3d542 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 25 Oct 2017 22:56:47 +0100 Subject: [PATCH] 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 --- webdav/webdav.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/webdav/webdav.go b/webdav/webdav.go index 59bdc11b0..91602ac7b 100644 --- a/webdav/webdav.go +++ b/webdav/webdav.go @@ -638,13 +638,17 @@ func (f *Fs) copyOrMove(src fs.Object, remote string, method string) (fs.Object, if err != nil { 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 opts := rest.Opts{ Method: method, Path: srcObj.filePath(), NoResponse: true, ExtraHeaders: map[string]string{ - "Destination": path.Join(f.endpoint.Path, dstPath), + "Destination": destinationURL.String(), "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") } + destinationURL, err := rest.URLJoin(f.endpoint, dstPath) + if err != nil { + return errors.Wrap(err, "DirMove couldn't join URL") + } + var resp *http.Response opts := rest.Opts{ Method: "MOVE", Path: addSlash(srcPath), NoResponse: true, ExtraHeaders: map[string]string{ - "Destination": addSlash(path.Join(f.endpoint.Path, dstPath)), + "Destination": addSlash(destinationURL.String()), "Overwrite": "F", }, }