Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use defer to invalidate ID Cache #3911

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/unreleased/clean-decomposedfs-idcache.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down