Skip to content

Commit 29a0fe5

Browse files
committed
run.go jobIds len check
1 parent a633f44 commit 29a0fe5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

models/actions/run.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,16 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
445445

446446
// TODO: When deleting a run, it should at lease delete artifacts, tasks logs, database record.
447447
func DeleteRun(ctx context.Context, repoID int64, run *ActionRun, jobs []*ActionRunJob) error {
448+
tasks := make(TaskList, 0)
449+
448450
jobIDs := container_module.FilterSlice(jobs, func(j *ActionRunJob) (int64, bool) {
449451
return j.ID, j.ID != 0
450452
})
451453

452-
tasks := make(TaskList, 0)
453-
if err := db.GetEngine(ctx).Where("repo_id = ?", repoID).In("job_id", jobIDs).Find(&tasks); err != nil {
454-
return err
454+
if len(jobIDs) > 0 {
455+
if err := db.GetEngine(ctx).Where("repo_id = ?", repoID).In("job_id", jobIDs).Find(&tasks); err != nil {
456+
return err
457+
}
455458
}
456459

457460
artifacts, err := db.Find[ActionArtifact](ctx, FindArtifactsOptions{

0 commit comments

Comments
 (0)