Remove special treatment of "" in stateful.List.
This commit is contained in:
+7
-6
@@ -346,7 +346,7 @@ func (state *state) rewrite() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a, _, err := state.list("")
|
||||
a, _, err := state.list("", true)
|
||||
if err != nil {
|
||||
os.Remove(tmpfile.Name())
|
||||
return err
|
||||
@@ -387,7 +387,10 @@ func (state *state) rewrite() error {
|
||||
}
|
||||
|
||||
// called locked
|
||||
func (state *state) list(group string) ([]*Stateful, string, error) {
|
||||
func (state *state) list(group string, all bool) ([]*Stateful, string, error) {
|
||||
if group != "" && all {
|
||||
return nil, "", errors.New("cannot specify both group and all")
|
||||
}
|
||||
_, err := state.load()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
@@ -398,11 +401,9 @@ func (state *state) list(group string) ([]*Stateful, string, error) {
|
||||
return a, state.etag(), nil
|
||||
}
|
||||
for _, t := range state.tokens {
|
||||
if group != "" {
|
||||
if t.Group != group {
|
||||
if !all && t.Group != group {
|
||||
continue
|
||||
}
|
||||
}
|
||||
a = append(a, t)
|
||||
}
|
||||
sort.Slice(a, func(i, j int) bool {
|
||||
@@ -420,7 +421,7 @@ func (state *state) list(group string) ([]*Stateful, string, error) {
|
||||
func (state *state) List(group string) ([]*Stateful, string, error) {
|
||||
state.mu.Lock()
|
||||
defer state.mu.Unlock()
|
||||
return state.list(group)
|
||||
return state.list(group, false)
|
||||
}
|
||||
|
||||
func List(group string) ([]*Stateful, string, error) {
|
||||
|
||||
Reference in New Issue
Block a user