mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-18 19:44:31 +08:00
Sort files so that folder is first.
This commit is contained in:
@@ -3,6 +3,8 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math"
|
"math"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"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)
|
parentPath := v1.FilePathToParentPath(req.Path)
|
||||||
|
|
||||||
return &api.ListFilesResponse{
|
return &api.ListFilesResponse{
|
||||||
|
Reference in New Issue
Block a user