fix(fs): remove old target object from cache before updating (#8352)

pull/8376/head
Yifan Gao 2025-04-12 17:09:46 +08:00 committed by GitHub
parent d0ee90cd11
commit c8470b9a2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package op
import (
"context"
stdpath "path"
"slices"
"time"
"github.com/Xhofe/go-cache"
@ -25,6 +26,12 @@ func updateCacheObj(storage driver.Driver, path string, oldObj model.Obj, newObj
key := Key(storage, path)
objs, ok := listCache.Get(key)
if ok {
for i, obj := range objs {
if obj.GetName() == newObj.GetName() {
objs = slices.Delete(objs, i, i+1)
break
}
}
for i, obj := range objs {
if obj.GetName() == oldObj.GetName() {
objs[i] = newObj