Remove related pipeline logs during pipeline deletion (#4572)

This commit is contained in:
Robert Kaussow 2024-12-17 09:09:03 +01:00 committed by GitHub
parent d0a61ee03b
commit e8216bc123
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -16,6 +16,7 @@ package datastore
import (
"github.com/rs/zerolog/log"
"xorm.io/xorm"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
)
@ -46,6 +47,12 @@ func (s storage) LogAppend(_ *model.Step, logEntries []*model.LogEntry) error {
}
func (s storage) LogDelete(step *model.Step) error {
_, err := s.engine.Where("step_id = ?", step.ID).Delete(new(model.LogEntry))
sess := s.engine.NewSession()
defer sess.Close()
return logDelete(sess, step.ID)
}
func logDelete(sess *xorm.Session, stepID int64) error {
_, err := sess.Where("step_id = ?", stepID).Delete(new(model.LogEntry))
return err
}

View file

@ -84,7 +84,7 @@ func (s storage) StepUpdate(step *model.Step) error {
}
func deleteStep(sess *xorm.Session, stepID int64) error {
if _, err := sess.Where("id = ?", stepID).Delete(new(model.LogEntry)); err != nil {
if err := logDelete(sess, stepID); err != nil {
return err
}
return wrapDelete(sess.ID(stepID).Delete(new(model.Step)))