Skip to content

Commit

Permalink
Merge pull request #242 from ktock/dentorder
Browse files Browse the repository at this point in the history
Make the order of directory entries deterministic
  • Loading branch information
AkihiroSuda authored Jan 18, 2021
2 parents 880da3a + 90d96f9 commit 8f544b4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"io"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -707,6 +708,11 @@ func (n *node) Readdir(ctx context.Context) (fusefs.DirStream, syscall.Errno) {
}
}

// Avoid undeterministic order of entries on each call
sort.Slice(ents, func(i, j int) bool {
return ents[i].Name < ents[j].Name
})

return fusefs.NewListDirStream(ents), 0
}

Expand Down

0 comments on commit 8f544b4

Please sign in to comment.