Remove notifications Fix (#6082)

Remove all the notifications for an empty rulesMap

Fixes #6053
master
Praveen raj Mani 6 years ago committed by Nitish Tiwari
parent 5c9354894b
commit 65e05a06fb
  1. 16
      cmd/notification.go

@ -192,11 +192,17 @@ func (sys *NotificationSys) AddRemoteTarget(bucketName string, target event.Targ
if targetMap == nil { if targetMap == nil {
targetMap = make(map[event.TargetID]event.RulesMap) targetMap = make(map[event.TargetID]event.RulesMap)
} }
targetMap[target.ID()] = rulesMap.Clone()
rulesMap = rulesMap.Clone()
targetMap[target.ID()] = rulesMap
sys.bucketRemoteTargetRulesMap[bucketName] = targetMap sys.bucketRemoteTargetRulesMap[bucketName] = targetMap
rulesMap = rulesMap.Clone()
rulesMap.Add(sys.bucketRulesMap[bucketName])
sys.bucketRulesMap[bucketName] = rulesMap
sys.Unlock() sys.Unlock()
sys.AddRulesMap(bucketName, rulesMap)
return nil return nil
} }
@ -341,8 +347,12 @@ func (sys *NotificationSys) AddRulesMap(bucketName string, rulesMap event.RulesM
rulesMap.Add(targetRulesMap) rulesMap.Add(targetRulesMap)
} }
rulesMap.Add(sys.bucketRulesMap[bucketName]) // Do not add for an empty rulesMap.
if len(rulesMap) == 0 {
delete(sys.bucketRulesMap, bucketName)
} else {
sys.bucketRulesMap[bucketName] = rulesMap sys.bucketRulesMap[bucketName] = rulesMap
}
} }
// RemoveRulesMap - removes rules map for bucket name. // RemoveRulesMap - removes rules map for bucket name.

Loading…
Cancel
Save