diff --git a/internal/command/download.go b/internal/command/download.go index e9306df..49b2d78 100644 --- a/internal/command/download.go +++ b/internal/command/download.go @@ -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 diff --git a/internal/functions/pandownload/download_task_unit.go b/internal/functions/pandownload/download_task_unit.go index 661048a..c0797f6 100644 --- a/internal/functions/pandownload/download_task_unit.go +++ b/internal/functions/pandownload/download_task_unit.go @@ -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)