feat(task): not fail immediately after failed upload in transfer tasks
This commit is contained in:
parent
c17cf1946a
commit
1f836a4b8b
1 changed files with 7 additions and 1 deletions
|
@ -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 新建中转任务
|
||||
|
|
Loading…
Add table
Reference in a new issue