|
|
@ -923,19 +923,25 @@ func (s *StateStore) KVSListKeys(prefix, seperator string) (uint64, []string, er |
|
|
|
var keys []string |
|
|
|
var keys []string |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
prefixLen := len(prefix) |
|
|
|
prefixLen := len(prefix) |
|
|
|
|
|
|
|
sepLen := len(seperator) |
|
|
|
last := "" |
|
|
|
last := "" |
|
|
|
for raw := range stream { |
|
|
|
for raw := range stream { |
|
|
|
ent := raw.(*structs.DirEntry) |
|
|
|
ent := raw.(*structs.DirEntry) |
|
|
|
after := ent.Key[prefixLen:] |
|
|
|
after := ent.Key[prefixLen:] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If there is no seperator, always accumulate
|
|
|
|
|
|
|
|
if sepLen == 0 { |
|
|
|
|
|
|
|
keys = append(keys, ent.Key) |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check for the seperator
|
|
|
|
// Check for the seperator
|
|
|
|
if idx := strings.Index(after, seperator); idx >= 0 { |
|
|
|
if idx := strings.Index(after, seperator); idx >= 0 { |
|
|
|
toSep := ent.Key[:prefixLen+idx+1] |
|
|
|
toSep := ent.Key[:prefixLen+idx+sepLen] |
|
|
|
if last != toSep { |
|
|
|
if last != toSep { |
|
|
|
keys = append(keys, toSep) |
|
|
|
keys = append(keys, toSep) |
|
|
|
last = toSep |
|
|
|
last = toSep |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
keys = append(keys, ent.Key) |
|
|
|
keys = append(keys, ent.Key) |
|
|
|
} |
|
|
|
} |
|
|
|