From f8997b833622710cdd6685930dd9d3eec7313575 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 15 Nov 2022 09:51:30 +0000 Subject: [PATCH] webdav: fix Move/Copy/DirMove when using -server-side-across-configs Before this change, when using -server-side-across-configs rclone would direct Move/Copy/DirMove to the destination server. However this should be directed to the source server. This is a little unclear in the RFC, but the name of the parameter "Destination:" seems clear and this is how dCache and Rucio have implemented it. See: https://forum.rclone.org/t/webdav-copy-request-implemented-incorrectly/34072/ --- backend/webdav/webdav.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go index 8a815cef8..251202948 100644 --- a/backend/webdav/webdav.go +++ b/backend/webdav/webdav.go @@ -991,6 +991,7 @@ func (f *Fs) copyOrMove(ctx context.Context, src fs.Object, remote string, metho } return nil, fs.ErrorCantMove } + srcFs := srcObj.fs dstPath := f.filePath(remote) err := f.mkParentDir(ctx, dstPath) if err != nil { @@ -1013,9 +1014,10 @@ func (f *Fs) copyOrMove(ctx context.Context, src fs.Object, remote string, metho if f.useOCMtime { opts.ExtraHeaders["X-OC-Mtime"] = fmt.Sprintf("%d", src.ModTime(ctx).Unix()) } - err = f.pacer.Call(func() (bool, error) { - resp, err = f.srv.Call(ctx, &opts) - return f.shouldRetry(ctx, resp, err) + // Direct the MOVE/COPY to the source server + err = srcFs.pacer.Call(func() (bool, error) { + resp, err = srcFs.srv.Call(ctx, &opts) + return srcFs.shouldRetry(ctx, resp, err) }) if err != nil { return nil, fmt.Errorf("Copy call failed: %w", err) @@ -1109,9 +1111,10 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string "Overwrite": "F", }, } - err = f.pacer.Call(func() (bool, error) { - resp, err = f.srv.Call(ctx, &opts) - return f.shouldRetry(ctx, resp, err) + // Direct the MOVE/COPY to the source server + err = srcFs.pacer.Call(func() (bool, error) { + resp, err = srcFs.srv.Call(ctx, &opts) + return srcFs.shouldRetry(ctx, resp, err) }) if err != nil { return fmt.Errorf("DirMove MOVE call failed: %w", err)