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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
a, _, err := state.list("")
|
a, _, err := state.list("", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(tmpfile.Name())
|
os.Remove(tmpfile.Name())
|
||||||
return err
|
return err
|
||||||
@@ -387,7 +387,10 @@ func (state *state) rewrite() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// called locked
|
// 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()
|
_, err := state.load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
@@ -398,11 +401,9 @@ func (state *state) list(group string) ([]*Stateful, string, error) {
|
|||||||
return a, state.etag(), nil
|
return a, state.etag(), nil
|
||||||
}
|
}
|
||||||
for _, t := range state.tokens {
|
for _, t := range state.tokens {
|
||||||
if group != "" {
|
if !all && t.Group != group {
|
||||||
if t.Group != group {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
a = append(a, t)
|
a = append(a, t)
|
||||||
}
|
}
|
||||||
sort.Slice(a, func(i, j int) bool {
|
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) {
|
func (state *state) List(group string) ([]*Stateful, string, error) {
|
||||||
state.mu.Lock()
|
state.mu.Lock()
|
||||||
defer state.mu.Unlock()
|
defer state.mu.Unlock()
|
||||||
return state.list(group)
|
return state.list(group, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func List(group string) ([]*Stateful, string, error) {
|
func List(group string) ([]*Stateful, string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user