Skip to content

Commit

Permalink
process containers BEFORE paging
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Jul 13, 2016
1 parent fd14caa commit 40ddb07
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions local/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,31 @@ func (l *location) Containers(prefix string, cursor string) ([]stow.Container, s
if err != nil {
return nil, "", err
}
cs, err := l.filesToContainers(path, files...)
if err != nil {
return nil, "", err
}
if cursor != stow.CursorStart {
// seek to the cursor
ok := false
for i, file := range files {
if file == cursor {
for i, c := range cs {
if c.ID() == cursor {
ok = true
files = files[i:]
cs = cs[i:]
break
}
}
if !ok {
return nil, "", stow.ErrBadCursor
}
}
if len(files) > l.pagesize {
cursor = files[l.pagesize]
files = files[:l.pagesize] // limit files to pagesize
} else if len(files) <= l.pagesize {
if len(cs) > l.pagesize {
cursor = cs[l.pagesize].ID()
cs = cs[:l.pagesize] // limit cs to pagesize
} else if len(cs) <= l.pagesize {
cursor = ""
}
cs, err := l.filesToContainers(path, files...)

return cs, cursor, err
}

Expand Down

0 comments on commit 40ddb07

Please sign in to comment.