Browse Source

verbose but cleaner logic to invalidate fuse cache

pull/2115/head
Chris Lu 4 years ago
parent
commit
e6ba2f9c37
  1. 21
      weed/filesys/meta_cache/meta_cache_subscribe.go

21
weed/filesys/meta_cache/meta_cache_subscribe.go

@ -40,12 +40,21 @@ func SubscribeMetaEvents(mc *MetaCache, selfSignature int32, client filer_pb.Fil
newEntry = filer.FromPbEntry(dir, message.NewEntry) newEntry = filer.FromPbEntry(dir, message.NewEntry)
} }
err := mc.AtomicUpdateEntryFromFiler(context.Background(), oldPath, newEntry) err := mc.AtomicUpdateEntryFromFiler(context.Background(), oldPath, newEntry)
if err == nil && message.OldEntry != nil {
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
mc.invalidateFunc(oldKey)
if message.NewEntry != nil {
key := util.NewFullPath(dir, message.NewEntry.Name)
mc.invalidateFunc(key)
if err == nil {
if message.OldEntry != nil && message.NewEntry != nil {
if message.OldEntry.Name == message.NewEntry.Name {
// no need to invalidate
} else {
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
mc.invalidateFunc(oldKey)
newKey := util.NewFullPath(dir, message.NewEntry.Name)
mc.invalidateFunc(newKey)
}
} else if message.OldEntry == nil && message.NewEntry != nil {
// no need to invaalidate
} else if message.OldEntry != nil && message.NewEntry == nil {
oldKey := util.NewFullPath(resp.Directory, message.OldEntry.Name)
mc.invalidateFunc(oldKey)
} }
} }

Loading…
Cancel
Save