robocanic commented on code in PR #1422:
URL: https://github.com/apache/dubbo-admin/pull/1422#discussion_r3001201492


##########
pkg/store/memory/store.go:
##########
@@ -63,14 +74,42 @@ func (rs *resourceStore) Start(_ runtime.Runtime, _ <-chan 
struct{}) error {
 }
 
 func (rs *resourceStore) Add(obj interface{}) error {
-       return rs.storeProxy.Add(obj)
+       if err := rs.storeProxy.Add(obj); err != nil {
+               return err
+       }
+       r, ok := obj.(coremodel.Resource)
+       if ok {
+               rs.addToTrees(r)
+       }
+       return nil
 }
 
 func (rs *resourceStore) Update(obj interface{}) error {
-       return rs.storeProxy.Update(obj)
+       r, ok := obj.(coremodel.Resource)
+       if ok {
+               // Get the old resource from the store to properly remove it 
from trees
+               oldObj, exists, err := rs.storeProxy.Get(r)
+               if exists && err == nil {
+                       if oldRes, ok := oldObj.(coremodel.Resource); ok {
+                               rs.removeFromTrees(oldRes)
+                       }
+               }
+       }
+       if err := rs.storeProxy.Update(obj); err != nil {
+               return err
+       }
+       if ok {
+               // Add new entry with updated values
+               rs.addToTrees(r)
+       }

Review Comment:
   same problem



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to