Fix multiple matches on different key hooks
This commit is contained in:
parent
b6977da0c4
commit
6b2fc1f37f
@ -211,6 +211,9 @@ func (server *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
|||||||
[]float64{rect.Max.X, rect.Max.Y},
|
[]float64{rect.Max.X, rect.Max.Y},
|
||||||
func(_, _ []float64, value interface{}) bool {
|
func(_, _ []float64, value interface{}) bool {
|
||||||
hook := value.(*Hook)
|
hook := value.(*Hook)
|
||||||
|
if hook.Key != d.key {
|
||||||
|
return true
|
||||||
|
}
|
||||||
var found bool
|
var found bool
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
if candidate == hook {
|
if candidate == hook {
|
||||||
|
@ -233,11 +233,9 @@ func (c *Server) cmdDelHook(msg *Message, chanCmd bool) (
|
|||||||
}
|
}
|
||||||
if hook, ok := c.hooks[name]; ok && hook.channel == chanCmd {
|
if hook, ok := c.hooks[name]; ok && hook.channel == chanCmd {
|
||||||
hook.Close()
|
hook.Close()
|
||||||
|
// remove hook from maps
|
||||||
delete(c.hooks, hook.Name)
|
delete(c.hooks, hook.Name)
|
||||||
delete(c.hooksOut, hook.Name)
|
delete(c.hooksOut, hook.Name)
|
||||||
|
|
||||||
d.updated = true
|
|
||||||
|
|
||||||
// remove hook from spatial index
|
// remove hook from spatial index
|
||||||
if hook != nil && hook.Fence != nil && hook.Fence.obj != nil {
|
if hook != nil && hook.Fence != nil && hook.Fence.obj != nil {
|
||||||
rect := hook.Fence.obj.Rect()
|
rect := hook.Fence.obj.Rect()
|
||||||
@ -246,6 +244,7 @@ func (c *Server) cmdDelHook(msg *Message, chanCmd bool) (
|
|||||||
[]float64{rect.Max.X, rect.Max.Y},
|
[]float64{rect.Max.X, rect.Max.Y},
|
||||||
hook)
|
hook)
|
||||||
}
|
}
|
||||||
|
d.updated = true
|
||||||
}
|
}
|
||||||
d.timestamp = time.Now()
|
d.timestamp = time.Now()
|
||||||
|
|
||||||
@ -277,16 +276,26 @@ func (c *Server) cmdPDelHook(msg *Message, channel bool) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
for name, h := range c.hooks {
|
for name, hook := range c.hooks {
|
||||||
if h.channel != channel {
|
if hook.channel != channel {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
match, _ := glob.Match(pattern, name)
|
match, _ := glob.Match(pattern, name)
|
||||||
if !match {
|
if !match {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
h.Close()
|
hook.Close()
|
||||||
delete(c.hooks, h.Name)
|
// remove hook from maps
|
||||||
|
delete(c.hooks, hook.Name)
|
||||||
|
delete(c.hooksOut, hook.Name)
|
||||||
|
// remove hook from spatial index
|
||||||
|
if hook != nil && hook.Fence != nil && hook.Fence.obj != nil {
|
||||||
|
rect := hook.Fence.obj.Rect()
|
||||||
|
c.hookTree.Delete(
|
||||||
|
[]float64{rect.Min.X, rect.Min.Y},
|
||||||
|
[]float64{rect.Max.X, rect.Max.Y},
|
||||||
|
hook)
|
||||||
|
}
|
||||||
d.updated = true
|
d.updated = true
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user