Merge branch 'feature/disable-exec' of github.com:Start9Labs/filebrowser into feature/disable-exec

This commit is contained in:
Keagan McClelland 2020-09-24 16:45:45 -06:00
commit 9d565c95f5

View File

@ -19,12 +19,10 @@ 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 r.Enabled {
if val, ok := r.Commands["before_"+evt]; ok {
for _, command := range val {
err := r.exec(command, "before_"+evt, path, dst, user)
@ -33,12 +31,14 @@ func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.Use
}
}
}
}
err := fn()
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)
@ -47,6 +47,7 @@ func (r *Runner) RunHook(fn func() error, evt, path, dst string, user *users.Use
}
}
}
}
return nil
}