Skip to content

Commit c8470b9

Browse files
authored
fix(fs): remove old target object from cache before updating (#8352)
1 parent d0ee90c commit c8470b9

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

internal/op/fs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package op
33
import (
44
"context"
55
stdpath "path"
6+
"slices"
67
"time"
78

89
"github.com/Xhofe/go-cache"
@@ -25,6 +26,12 @@ func updateCacheObj(storage driver.Driver, path string, oldObj model.Obj, newObj
2526
key := Key(storage, path)
2627
objs, ok := listCache.Get(key)
2728
if ok {
29+
for i, obj := range objs {
30+
if obj.GetName() == newObj.GetName() {
31+
objs = slices.Delete(objs, i, i+1)
32+
break
33+
}
34+
}
2835
for i, obj := range objs {
2936
if obj.GetName() == oldObj.GetName() {
3037
objs[i] = newObj

0 commit comments

Comments
 (0)