wal: don't use path.Base to get changegroup value

If a changegroup contains a slash then it'll be cut the the last string after
the slash
This commit is contained in:
Simone Gotti 2019-03-28 15:42:45 +01:00
parent 0f9a5f9c4b
commit 805099b693
1 changed files with 2 additions and 2 deletions

View File

@ -344,12 +344,12 @@ func (w *WalManager) watcher(ctx context.Context) error {
switch ev.Type { switch ev.Type {
case mvccpb.PUT: case mvccpb.PUT:
w.changes.Lock() w.changes.Lock()
changeGroup := path.Base(string(ev.Kv.Key)) changeGroup := strings.TrimPrefix(string(ev.Kv.Key), etcdChangeGroupsDir+"/")
w.changes.putChangeGroup(changeGroup, ev.Kv.ModRevision) w.changes.putChangeGroup(changeGroup, ev.Kv.ModRevision)
w.changes.Unlock() w.changes.Unlock()
case mvccpb.DELETE: case mvccpb.DELETE:
w.changes.Lock() w.changes.Lock()
changeGroup := path.Base(string(ev.Kv.Key)) changeGroup := strings.TrimPrefix(string(ev.Kv.Key), etcdChangeGroupsDir+"/")
w.changes.removeChangeGroup(changeGroup) w.changes.removeChangeGroup(changeGroup)
w.changes.Unlock() w.changes.Unlock()
} }