From f702fbf47ffe9bafe54e0e6b4841fb33527c3f63 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Mon, 22 May 2023 09:17:30 +0200 Subject: [PATCH] use defer to invalidate id cache Signed-off-by: jkoberg --- changelog/unreleased/clean-decomposedfs-idcache.md | 1 + pkg/storage/utils/decomposedfs/tree/tree.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/clean-decomposedfs-idcache.md b/changelog/unreleased/clean-decomposedfs-idcache.md index 16178a5b20..db9d342c6e 100644 --- a/changelog/unreleased/clean-decomposedfs-idcache.md +++ b/changelog/unreleased/clean-decomposedfs-idcache.md @@ -4,4 +4,5 @@ decomposedfs' subpackage `tree` uses an idCache to avoid reading too often from properly cleaned, but when renaming a file (= move with same parent) the cache wasn't cleaned. This lead to strange behaviour when uploading files with the same name and renaming them +https://github.com/cs3org/reva/pull/3911 https://github.com/cs3org/reva/pull/3903 diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index ac5ab04c50..d092f52d65 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -235,7 +235,7 @@ func (t *Tree) Move(ctx context.Context, oldNode *node.Node, newNode *node.Node) } // remove cache entry in any case to avoid inconsistencies - _ = t.idCache.Delete(filepath.Join(oldNode.ParentPath(), oldNode.Name)) + defer func() { _ = t.idCache.Delete(filepath.Join(oldNode.ParentPath(), oldNode.Name)) }() // Always target the old node ID for xattr updates. // The new node id is empty if the target does not exist @@ -418,7 +418,7 @@ func (t *Tree) ListFolder(ctx context.Context, n *node.Node) ([]*node.Node, erro func (t *Tree) Delete(ctx context.Context, n *node.Node) (err error) { path := filepath.Join(n.ParentPath(), n.Name) // remove entry from cache immediately to avoid inconsistencies - _ = t.idCache.Delete(path) + defer func() { _ = t.idCache.Delete(path) }() deletingSharedResource := ctx.Value(appctx.DeletingSharedResource)