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 cc1b475
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3805,24 +3805,26 @@ 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
total := limit + 1
sCursor := ""
if cursor == nil {
startKey = m.entryKey(inode, "")

if offset > 0 {
total += offset
}
} else {
startKey = nextKey(m.entryKey(inode, cursor.(string)))
sCursor = cursor.(string)
}
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:] // skip the cursor
}
if total > limit && offset <= len(keys) {
keys, vals = keys[offset:], vals[offset:]
}
Expand Down

0 comments on commit cc1b475

Please sign in to comment.