Skip to content

Commit 1070de8

Browse files
authored
fs: return sort entries when sort-dir is true (#6442)
Signed-off-by: swj <[email protected]>
1 parent 6e90dc0 commit 1070de8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/fs/fs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"os"
2626
"path"
2727
"runtime/trace"
28+
"sort"
2829
"strconv"
2930
"strings"
3031
"sync"
@@ -1398,6 +1399,11 @@ func (f *File) Readdir(ctx meta.Context, count int) (fi []os.FileInfo, err sysca
13981399
if err != 0 {
13991400
return
14001401
}
1402+
if f.fs.conf.Meta.SortDir {
1403+
sort.Slice(inodes[2:], func(i, j int) bool {
1404+
return string(inodes[i].Name) < string(inodes[j].Name)
1405+
})
1406+
}
14011407
// skip . and ..
14021408
for _, n := range inodes[2:] {
14031409
i := AttrToFileInfo(n.Inode, n.Attr)

0 commit comments

Comments
 (0)