From 730d95edc864ac7c96c0b4332e3e3ee0bef686bc Mon Sep 17 00:00:00 2001 From: Ziming Zhang Date: Wed, 7 Aug 2019 17:52:47 +0800 Subject: [PATCH] check rule conflict Signed-off-by: Ziming Zhang Change-Id: I95f7e683b30fa6059b5bb49a2fc8f78dd7276079 --- src/core/api/retention.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/core/api/retention.go b/src/core/api/retention.go index 9899fde00..885c0de70 100644 --- a/src/core/api/retention.go +++ b/src/core/api/retention.go @@ -1,7 +1,6 @@ package api import ( - "crypto/sha256" "encoding/json" "errors" "fmt" @@ -242,12 +241,10 @@ func (r *RetentionAPI) checkRuleConflict(p *policy.Metadata) error { tid := rule.ID rule.ID = 0 bs, _ := json.Marshal(rule) - s := sha256.New() - h := s.Sum(bs) - if old, exists := temp[string(h)]; exists { + if old, exists := temp[string(bs)]; exists { return fmt.Errorf("rule %d is conflict with rule %d", n, old) } - temp[string(h)] = tid + temp[string(bs)] = tid rule.ID = tid } return nil