mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-13 01:13:40 +08:00
Sort files so that folder is first.
This commit is contained in:
@@ -3,6 +3,8 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
@@ -456,6 +458,17 @@ func (s *WorkflowServer) ListFiles(ctx context.Context, req *api.ListFilesReques
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(apiFiles, func(i, j int) bool {
|
||||
fileI := apiFiles[i]
|
||||
fileJ := apiFiles[j]
|
||||
|
||||
if fileI.Directory && !fileJ.Directory {
|
||||
return true
|
||||
}
|
||||
|
||||
return strings.Compare(fileI.Path, fileJ.Path) < 0
|
||||
})
|
||||
|
||||
parentPath := v1.FilePathToParentPath(req.Path)
|
||||
|
||||
return &api.ListFilesResponse{
|
||||
|
Reference in New Issue
Block a user