From 1f836a4b8b941290cd5516b09499b8833ef3e7c3 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 17 Oct 2022 19:26:09 +0800 Subject: [PATCH] feat(task): not fail immediately after failed upload in transfer tasks --- pkg/task/tranfer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/task/tranfer.go b/pkg/task/tranfer.go index aee1ea5..54bba47 100644 --- a/pkg/task/tranfer.go +++ b/pkg/task/tranfer.go @@ -3,6 +3,7 @@ package task import ( "context" "encoding/json" + "fmt" "path" "path/filepath" "strings" @@ -94,6 +95,7 @@ func (job *TransferTask) Do() { } successCount := 0 + errorList := make([]string, 0, len(job.TaskProps.Src)) for _, file := range job.TaskProps.Src { dst := path.Join(job.TaskProps.Dst, filepath.Base(file)) if job.TaskProps.TrimPath { @@ -127,13 +129,17 @@ func (job *TransferTask) Do() { } if err != nil { - job.SetErrorMsg("Failed to transfer file.", err) + errorList = append(errorList, err.Error()) } else { successCount++ job.TaskModel.SetProgress(successCount) } } + if len(errorList) > 0 { + job.SetErrorMsg("Failed to transfer one or more file(s).", fmt.Errorf(strings.Join(errorList, "\n"))) + } + } // NewTransferTask 新建中转任务