Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/wshrpc/wshremote/wshremote_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"log"
"os"
"path/filepath"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -57,6 +58,17 @@ func (impl *ServerImpl) remoteStreamFileDir(ctx context.Context, path string, by
if err != nil {
return fmt.Errorf("cannot open dir %q: %w", path, err)
}
sort.Slice(innerFilesEntries, func(i, j int) bool {
iInfo, iErr := innerFilesEntries[i].Info()
jInfo, jErr := innerFilesEntries[j].Info()
if iErr != nil {
return false
}
if jErr != nil {
return true
}
return iInfo.ModTime().After(jInfo.ModTime())
})
if byteRange.All {
if len(innerFilesEntries) > wshrpc.MaxDirSize {
innerFilesEntries = innerFilesEntries[:wshrpc.MaxDirSize]
Expand Down
2 changes: 1 addition & 1 deletion pkg/wshrpc/wshrpctypes_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const (
// MaxFileSize is the maximum file size that can be read
MaxFileSize = 50 * 1024 * 1024 // 50M
// MaxDirSize is the maximum number of entries that can be read in a directory
MaxDirSize = 1024
MaxDirSize = 5000
// FileChunkSize is the size of the file chunk to read
FileChunkSize = 64 * 1024
// DirChunkSize is the size of the directory chunk to read
Expand Down