Browse Source

sort model by time desc

tags/v1.21.12.1
lewis 4 years ago
parent
commit
80d98dd135
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"
"net/url"
"path"
"sort"
"strconv"
"strings"

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


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

@@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"regexp"
"sort"
"strconv"
"strings"
"time"
@@ -533,6 +534,10 @@ func CloudBrainShowModels(ctx *context.Context) {
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["Dirs"] = fileInfos
ctx.Data["task"] = task


Loading…
Cancel
Save