MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / Update

Method Update

inventory/task.go:142–163  ·  view source on GitHub ↗
(ctx context.Context, task *ent.Task, args *TaskArgs)

Source from the content-addressed store, hash-verified

140}
141
142func (c *taskClient) Update(ctx context.Context, task *ent.Task, args *TaskArgs) (*ent.Task, error) {
143 stm := c.client.Task.UpdateOne(task).
144 SetPublicState(args.PublicState)
145
146 task.PublicState = args.PublicState
147
148 if task.PrivateState != "" {
149 stm.SetPrivateState(task.PrivateState)
150 task.PrivateState = args.PrivateState
151 }
152
153 if task.Status != "" {
154 stm.SetStatus(args.Status)
155 task.Status = args.Status
156 }
157
158 if err := stm.Exec(ctx); err != nil {
159 return nil, fmt.Errorf("failed to create task: %w", err)
160 }
161
162 return task, nil
163}
164
165func (c *taskClient) GetPendingTasks(ctx context.Context, taskType ...string) ([]*ent.Task, error) {
166 tasks, err := withTaskEagerLoading(ctx, c.client.Task.Query()).

Callers

nothing calls this directly

Calls 5

SetStatusMethod · 0.65
ExecMethod · 0.65
SetPublicStateMethod · 0.45
UpdateOneMethod · 0.45
SetPrivateStateMethod · 0.45

Tested by

no test coverage detected