Skip to content

Commit

Permalink
fix kv
Browse files Browse the repository at this point in the history
Signed-off-by: jiefenghuang <[email protected]>
  • Loading branch information
jiefenghuang committed Sep 27, 2024
1 parent 347fd0e commit a55b1b3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3805,24 +3805,29 @@ func (m *kvMeta) newDirStream(inode Ino, plus bool, entries []*Entry) DirStream
func (m *kvMeta) getDirFetcher() dirFetcher {
return func(ctx Context, inode Ino, cursor interface{}, offset, limit int, plus bool) (interface{}, []*Entry, error) {
var startKey []byte
total := limit
sCursor := ""
var total int
if cursor == nil {
startKey = m.entryKey(inode, "")

if offset > 0 {
total += offset
}
} else {
startKey = nextKey(m.entryKey(inode, cursor.(string)))
limit += 1 // skip the cursor
sCursor = cursor.(string)
}
total += limit
startKey = m.entryKey(inode, sCursor)
endKey := nextKey(m.entryKey(inode, ""))

keys, vals, err := m.scan(startKey, endKey, total, nil)
if err != nil {
return nil, nil, err
}

// skip offset
if cursor != nil {
keys, vals = keys[1:], vals[1:]
}

if total > limit && offset <= len(keys) {
keys, vals = keys[offset:], vals[offset:]
}
Expand Down

0 comments on commit a55b1b3

Please sign in to comment.