mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 06:26:30 +00:00
Remove related pipeline logs during pipeline deletion (#4572)
This commit is contained in:
parent
d0a61ee03b
commit
e8216bc123
2 changed files with 9 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)))
|
||||
|
|
Loading…
Reference in a new issue