From c8470b9a2a08276e7e8517caa70e6d10812a9978 Mon Sep 17 00:00:00 2001 From: Yifan Gao Date: Sat, 12 Apr 2025 17:09:46 +0800 Subject: [PATCH] fix(fs): remove old target object from cache before updating (#8352) --- internal/op/fs.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/op/fs.go b/internal/op/fs.go index 01727e75..99c2fe34 100644 --- a/internal/op/fs.go +++ b/internal/op/fs.go @@ -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