Browse Source

Merge pull request '云脑任务模型下载页面文件列表按修改时间降序排列' (#840) from download-model-error into V20211115

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/840
Reviewed-by: ychao_1983 <ychao_1983@sina.com>
pull/845/head
ychao_1983 3 years ago
parent
commit
b71c7cfdb0
2 changed files with 9 additions and 0 deletions
  1. +4
    -0
      modules/storage/obs.go
  2. +5
    -0
      routers/repo/cloudbrain.go

+ 4
- 0
modules/storage/obs.go View File

@@ -8,6 +8,7 @@ import (
"io" "io"
"net/url" "net/url"
"path" "path"
"sort"
"strconv" "strconv"
"strings" "strings"


@@ -222,6 +223,9 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) {
} }
fileInfos = append(fileInfos, fileInfo) fileInfos = append(fileInfos, fileInfo)
} }
sort.Slice(fileInfos, func(i, j int) bool {
return fileInfos[i].ModTime > fileInfos[j].ModTime
})
return fileInfos, err return fileInfos, err
} else { } else {
if obsError, ok := err.(obs.ObsError); ok { if obsError, ok := err.(obs.ObsError); ok {


+ 5
- 0
routers/repo/cloudbrain.go View File

@@ -10,6 +10,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"regexp" "regexp"
"sort"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -533,6 +534,10 @@ func CloudBrainShowModels(ctx *context.Context) {
fileInfos[i].ModTime = temp.Local().Format("2006-01-02 15:04:05") fileInfos[i].ModTime = temp.Local().Format("2006-01-02 15:04:05")
} }


sort.Slice(fileInfos, func(i, j int) bool {
return fileInfos[i].ModTime > fileInfos[j].ModTime
})

ctx.Data["Path"] = dirArray ctx.Data["Path"] = dirArray
ctx.Data["Dirs"] = fileInfos ctx.Data["Dirs"] = fileInfos
ctx.Data["task"] = task ctx.Data["task"] = task


Loading…
Cancel
Save