mirror of
https://github.com/rclone/rclone.git
synced 2025-12-16 00:04:40 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user