Sort files so that folder is first.

This commit is contained in:
Andrey Melnikov
2020-03-02 11:05:48 -08:00
parent 0d27a38c98
commit c36e383a16

View File

@@ -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{