Skip to content

Commit

Permalink
Merge pull request #3911 from kobergj/UseDeferToInvalidateCache
Browse files Browse the repository at this point in the history
Use defer to invalidate ID Cache
  • Loading branch information
kobergj authored May 22, 2023
2 parents 131bdf1 + f702fbf commit fde10c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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

0 comments on commit fde10c4

Please sign in to comment.