action.Parent

This commit is contained in:
Sebastian Frank 2021-08-12 16:55:37 +02:00
parent f91cd6e28e
commit 130d4fedc7
Signed by: apairon
GPG Key ID: A0E05A8199CE3F57

View File

@ -47,6 +47,7 @@ type ActionConfig struct {
OnError []ActionConfig `yaml:"onError"` OnError []ActionConfig `yaml:"onError"`
_dirConf *DirectoryConfig _dirConf *DirectoryConfig
Parent *ActionConfig `yaml:"-"`
} }
type DirectoryConfig struct { type DirectoryConfig struct {
@ -244,6 +245,7 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
log.Printf("path: %s; action: %s; error %s", eventInfo.Path(), action.Id, err) log.Printf("path: %s; action: %s; error %s", eventInfo.Path(), action.Id, err)
for _, aE := range action.OnError { for _, aE := range action.OnError {
aE._dirConf = action._dirConf aE._dirConf = action._dirConf
aE.Parent = action
_c, _ := runAction(&aE, eventInfo, ctx) _c, _ := runAction(&aE, eventInfo, ctx)
contin = contin && _c contin = contin && _c
if !contin { if !contin {
@ -253,6 +255,7 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
} else { } else {
for _, aS := range action.OnSuccess { for _, aS := range action.OnSuccess {
aS._dirConf = action._dirConf aS._dirConf = action._dirConf
aS.Parent = action
_c, errS := runAction(&aS, eventInfo, ctx) _c, errS := runAction(&aS, eventInfo, ctx)
contin = contin && _c contin = contin && _c
if errS != nil { if errS != nil {