From fa8ed5d2295d900b2a7c102d32164a399cfca88f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Oct 2022 00:55:17 -0400 Subject: [PATCH] fix: respect PLUGIN_PATH when checking if a plugin trigger exists Without this, upgrades may fail if the user has enabled a plugin which implements a trigger that is checked for during an upgrade. --- plugins/common/subprocess.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index d46b2b2d9..642b06c80 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -132,12 +132,13 @@ func PlugnTriggerSetup(triggerName string, args ...string) *sh.Session { // PlugnTriggerExists returns whether a plugin trigger exists (ignoring the existence of any within the 20_events plugin) func PlugnTriggerExists(triggerName string) bool { - pluginPath := MustGetEnv("PLUGIN_ENABLED_PATH") - glob := filepath.Join(pluginPath, "*", triggerName) + pluginPath := MustGetEnv("PLUGIN_PATH") + pluginPathPrefix := filepath.Join(pluginPath, "enabled") + glob := filepath.Join(pluginPathPrefix, "*", triggerName) exists := false files, _ := filepath.Glob(glob) for _, file := range files { - plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/"+triggerName), pluginPath), "/") + plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/"+triggerName), pluginPathPrefix), "/") if plugin != "20_events" { exists = true break