mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 05:16:38 +08:00
bug处理优化
bug处理优化
This commit is contained in:
@@ -34,6 +34,7 @@ type BackgroundTask struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
Details []string `json:"details,omitempty"`
|
||||
Metrics map[string]int64 `json:"metrics,omitempty"`
|
||||
Items []TaskItemRecord `json:"items,omitempty"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
FinishedAt *time.Time `json:"finished_at,omitempty"`
|
||||
@@ -46,6 +47,7 @@ type TaskUpdate struct {
|
||||
Message string
|
||||
Details []string
|
||||
Metrics map[string]int64
|
||||
Items []TaskItemRecord
|
||||
}
|
||||
|
||||
type TaskSnapshot struct {
|
||||
@@ -214,6 +216,9 @@ func applyTaskUpdate(task *BackgroundTask, update TaskUpdate) {
|
||||
if update.Metrics != nil {
|
||||
task.Metrics = cloneTaskMetrics(update.Metrics)
|
||||
}
|
||||
if update.Items != nil {
|
||||
task.Items = append([]TaskItemRecord(nil), update.Items...)
|
||||
}
|
||||
}
|
||||
|
||||
func cloneBackgroundTask(task BackgroundTask) BackgroundTask {
|
||||
@@ -221,6 +226,9 @@ func cloneBackgroundTask(task BackgroundTask) BackgroundTask {
|
||||
if task.Details != nil {
|
||||
task.Details = append([]string(nil), task.Details...)
|
||||
}
|
||||
if task.Items != nil {
|
||||
task.Items = append([]TaskItemRecord(nil), task.Items...)
|
||||
}
|
||||
if task.FinishedAt != nil {
|
||||
finishedAt := *task.FinishedAt
|
||||
task.FinishedAt = &finishedAt
|
||||
|
||||
Reference in New Issue
Block a user