fix: sort dirs correctly

Signed-off-by: jolheiser <git@jolheiser.com>
main
jolheiser 2024-09-24 12:17:40 -05:00
parent 4fbb4cf289
commit 9f70cc24cd
No known key found for this signature in database
1 changed files with 5 additions and 2 deletions

View File

@ -98,7 +98,7 @@ func (r Repo) Dir(ref, path string) ([]FileInfo, error) {
}
}
fis := make([]FileInfo, 0)
fis := make([]FileInfo, 0, len(t.Entries))
for _, entry := range t.Entries {
fm, err := entry.Mode.ToOSFileMode()
if err != nil {
@ -118,7 +118,10 @@ func (r Repo) Dir(ref, path string) ([]FileInfo, error) {
sort.Slice(fis, func(i, j int) bool {
fi1 := fis[i]
fi2 := fis[j]
return (fi1.IsDir && !fi2.IsDir) || fi1.Name() < fi2.Name()
if fi1.IsDir != fi2.IsDir {
return fi1.IsDir
}
return fi1.Name() < fi2.Name()
})
return fis, nil