From 00e671e9b9c60120aa671d75b3c798621eae08cf Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 24 Sep 2020 10:17:02 -0600 Subject: [PATCH] still run fn when exec disabled --- runner/runner.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/runner/runner.go b/runner/runner.go index 28ccd65a..9d8cc70c 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -19,17 +19,16 @@ type Runner struct { // 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 { - if !r.Enabled { - return nil - } path = user.FullPath(path) dst = user.FullPath(dst) - if val, ok := r.Commands["before_"+evt]; ok { - for _, command := range val { - err := r.exec(command, "before_"+evt, path, dst, user) - if err != nil { - return err + if r.Enabled { + if val, ok := r.Commands["before_"+evt]; ok { + for _, command := range val { + err := r.exec(command, "before_"+evt, path, dst, user) + 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 } - if val, ok := r.Commands["after_"+evt]; ok { - for _, command := range val { - err := r.exec(command, "after_"+evt, path, dst, user) - if err != nil { - return err + if r.Enabled { + if val, ok := r.Commands["after_"+evt]; ok { + for _, command := range val { + err := r.exec(command, "after_"+evt, path, dst, user) + if err != nil { + return err + } } } }