From b30cd2da60eb7541f69afa3d7a6936e101b0b7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 15 Jun 2023 15:16:02 +0200 Subject: [PATCH] drop O_CREATE for messagepack backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/no-o-create-for-messagepack.md | 3 +++ pkg/storage/utils/decomposedfs/tree/tree.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/no-o-create-for-messagepack.md diff --git a/changelog/unreleased/no-o-create-for-messagepack.md b/changelog/unreleased/no-o-create-for-messagepack.md new file mode 100644 index 0000000000..c3b19a0282 --- /dev/null +++ b/changelog/unreleased/no-o-create-for-messagepack.md @@ -0,0 +1,3 @@ +Bugfix: msgpack backend no longer creates empty file when propagating + +https://github.com/cs3org/reva/pull/3980 \ No newline at end of file diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index f809eec856..9bfb71f84d 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -754,10 +754,12 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node, sizeDiff int64) (err switch t.lookup.MetadataBackend().(type) { case metadata.MessagePackBackend: parentFilename = t.lookup.MetadataBackend().MetadataPath(n.ParentPath()) - f, err = lockedfile.OpenFile(parentFilename, os.O_RDWR|os.O_CREATE, 0600) + // no need to O_CREATE the file, we can use the metadata file. Actually, we want to error if the parent does not exist! + f, err = lockedfile.OpenFile(parentFilename, os.O_RDWR, 0600) case metadata.XattrsBackend: // we have to use dedicated lockfiles to lock directories // this only works because the xattr backend also locks folders with separate lock files + // we need to O_CREATE a lockfile if it does not exist, yet parentFilename = n.ParentPath() + filelocks.LockFileSuffix f, err = lockedfile.OpenFile(parentFilename, os.O_RDWR|os.O_CREATE, 0600) }