(ctx context.Context)
| 93 | } |
| 94 | |
| 95 | func (m *ExplicitEntityRecycleTask) Do(ctx context.Context) (task.Status, error) { |
| 96 | dep := dependency.FromContext(ctx) |
| 97 | fm := NewFileManager(dep, inventory.UserFromContext(ctx)).(*manager) |
| 98 | |
| 99 | // unmarshal state |
| 100 | state := &ExplicitEntityRecycleTaskState{} |
| 101 | if err := json.Unmarshal([]byte(m.State()), state); err != nil { |
| 102 | return task.StatusError, fmt.Errorf("failed to unmarshal state: %w", err) |
| 103 | } |
| 104 | |
| 105 | // recycle entities |
| 106 | err := fm.RecycleEntities(ctx, false, state.EntityIDs...) |
| 107 | if err != nil { |
| 108 | appendAe(&state.Errors, err) |
| 109 | privateState, err := json.Marshal(state) |
| 110 | if err != nil { |
| 111 | return task.StatusError, fmt.Errorf("failed to marshal state: %w", err) |
| 112 | } |
| 113 | m.Task.PrivateState = string(privateState) |
| 114 | return task.StatusError, err |
| 115 | } |
| 116 | |
| 117 | return task.StatusCompleted, nil |
| 118 | } |
| 119 | |
| 120 | type ( |
| 121 | EntityRecycleRoutineTask struct { |
nothing calls this directly
no test coverage detected