still run fn when exec disabled

This commit is contained in:
Aiden McClelland 2020-09-24 10:17:02 -06:00
parent dba8d53c9f
commit 00e671e9b9

View File

@ -19,17 +19,16 @@ type Runner struct {
// RunHook runs the hooks for the before and after event. // RunHook runs the hooks for the before and after event.
func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.User) error { func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.User) error {
if !r.Enabled {
return nil
}
path = user.FullPath(path) path = user.FullPath(path)
dst = user.FullPath(dst) dst = user.FullPath(dst)
if val, ok := r.Commands["before_"+evt]; ok { if r.Enabled {
for _, command := range val { if val, ok := r.Commands["before_"+evt]; ok {
err := r.exec(command, "before_"+evt, path, dst, user) for _, command := range val {
if err != nil { err := r.exec(command, "before_"+evt, path, dst, user)
return err if err != nil {
return err
}
} }
} }
} }
@ -39,11 +38,13 @@ func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.Use
return err return err
} }
if val, ok := r.Commands["after_"+evt]; ok { if r.Enabled {
for _, command := range val { if val, ok := r.Commands["after_"+evt]; ok {
err := r.exec(command, "after_"+evt, path, dst, user) for _, command := range val {
if err != nil { err := r.exec(command, "after_"+evt, path, dst, user)
return err if err != nil {
return err
}
} }
} }
} }