From 73beae147f4d2673fe61ae1085667e29062d4b23 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 26 Jun 2023 17:52:31 +0100 Subject: [PATCH] webdav: Fix modtime on server side copy for owncloud and nextcloud Before this change a server side copy did not preserve the modtime. This used to work on nextcloud but at some point it started ignoring the `X-Oc-Mtime` header. This patch sets the modtime explicitly after a server side copy if the `X-Oc-Mtime` wasn't accepted. This problem was discovered in the integration tests. --- backend/webdav/webdav.go | 7 +++++++ fstest/test_all/config.yaml | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go index 206b11bd1..397cd0b92 100644 --- a/backend/webdav/webdav.go +++ b/backend/webdav/webdav.go @@ -1068,6 +1068,13 @@ func (f *Fs) copyOrMove(ctx context.Context, src fs.Object, remote string, metho if err != nil { return nil, fmt.Errorf("copy NewObject failed: %w", err) } + if f.useOCMtime && resp.Header.Get("X-OC-Mtime") != "accepted" && f.propsetMtime { + fs.Debugf(dstObj, "Setting modtime after copy to %v", src.ModTime(ctx)) + err = dstObj.SetModTime(ctx, src.ModTime(ctx)) + if err != nil { + return nil, fmt.Errorf("failed to set modtime: %w", err) + } + } return dstObj, nil } diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml index 413ed60d1..89a2bd46b 100644 --- a/fstest/test_all/config.yaml +++ b/fstest/test_all/config.yaml @@ -333,10 +333,6 @@ backends: ignore: - TestIntegration/FsMkdir/FsEncoding/punctuation - TestIntegration/FsMkdir/FsEncoding/invalid_UTF-8 - - TestIntegration/FsMkdir/FsPutFiles/FsCopy - - TestCopyFileCopyDest - - TestServerSideCopy - - TestSyncCopyDest fastlist: false - backend: "webdav" remote: "TestWebdavRclone:"