sort by file name for download file list

This commit is contained in:
tickstep
2025-03-23 14:18:04 +08:00
parent a86a464e67
commit 0e0486914c
2 changed files with 12 additions and 0 deletions
+7
View File
@@ -33,6 +33,7 @@ import (
"path"
"path/filepath"
"runtime"
"sort"
)
type (
@@ -397,6 +398,12 @@ func RunDownload(paths []string, options *DownloadOptions) {
fmt.Printf("文件不存在: %s\n", paths[k])
continue
}
// 排序,按名称排序,从小到大
sort.Slice(fileList, func(i, j int) bool {
return fileList[i].FileName < fileList[j].FileName
})
// 逐一下载
for _, f := range fileList {
newCfg := *cfg
@@ -35,6 +35,7 @@ import (
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"
"time"
@@ -552,6 +553,10 @@ func (dtu *DownloadTaskUnit) Run() (result *taskframework.TaskUnitRunResult) {
}
time.Sleep(1 * time.Second)
// 排序,按名称排序,从小到大
sort.Slice(fileList, func(i, j int) bool {
return fileList[i].FileName < fileList[j].FileName
})
// 创建对应的任务进行下载
for k := range fileList {
fileList[k].Path = path.Join(dtu.FilePanPath, fileList[k].FileName)