feat(task): not fail immediately after failed upload in transfer tasks

pull/1519/head
HFO4 2 years ago
parent c17cf1946a
commit 1f836a4b8b

@ -3,6 +3,7 @@ package task
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
@ -94,6 +95,7 @@ func (job *TransferTask) Do() {
} }
successCount := 0 successCount := 0
errorList := make([]string, 0, len(job.TaskProps.Src))
for _, file := range job.TaskProps.Src { for _, file := range job.TaskProps.Src {
dst := path.Join(job.TaskProps.Dst, filepath.Base(file)) dst := path.Join(job.TaskProps.Dst, filepath.Base(file))
if job.TaskProps.TrimPath { if job.TaskProps.TrimPath {
@ -127,13 +129,17 @@ func (job *TransferTask) Do() {
} }
if err != nil { if err != nil {
job.SetErrorMsg("Failed to transfer file.", err) errorList = append(errorList, err.Error())
} else { } else {
successCount++ successCount++
job.TaskModel.SetProgress(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 新建中转任务 // NewTransferTask 新建中转任务

Loading…
Cancel
Save