Skip to content

Commit 8f544b4

Browse files
authoredJan 18, 2021
Merge pull request #242 from ktock/dentorder
Make the order of directory entries deterministic
2 parents 880da3a + 90d96f9 commit 8f544b4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎fs/fs.go

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"io"
4646
"os"
4747
"path/filepath"
48+
"sort"
4849
"strconv"
4950
"strings"
5051
"sync"
@@ -707,6 +708,11 @@ func (n *node) Readdir(ctx context.Context) (fusefs.DirStream, syscall.Errno) {
707708
}
708709
}
709710

711+
// Avoid undeterministic order of entries on each call
712+
sort.Slice(ents, func(i, j int) bool {
713+
return ents[i].Name < ents[j].Name
714+
})
715+
710716
return fusefs.NewListDirStream(ents), 0
711717
}
712718

0 commit comments

Comments
 (0)
Please sign in to comment.