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.
This commit is contained in:
Nick Craig-Wood 2023-06-26 17:52:31 +01:00
parent 92f8e476b7
commit 73beae147f
2 changed files with 7 additions and 4 deletions

View File

@ -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
}

View File

@ -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:"