Bladeren bron

feat():Delete alarm

EMqmyd 4 jaren geleden
bovenliggende
commit
5293455b54
1 gewijzigde bestanden met toevoegingen van 4 en 17 verwijderingen
  1. 4 17
      plugins/manager.go

+ 4 - 17
plugins/manager.go

@@ -276,14 +276,10 @@ func (m *Manager) Register(t PluginType, j *Plugin) error {
 		}
 		return fmt.Errorf("fail to unzip file %s: %s", uri, err)
 	}
-	confDir, err := common.GetConfLoc()
-	if nil != err {
-		return err
-	}
 	if SINK == t {
-		readSinkMetaFile(path.Join(confDir, PluginTypes[t], name+`.json`))
+		readSinkMetaFile(path.Join(m.etcDir, PluginTypes[t], name+`.json`))
 	} else if SOURCE == t {
-		readSourceMetaFile(path.Join(confDir, PluginTypes[t], name+`.json`))
+		readSourceMetaFile(path.Join(m.etcDir, PluginTypes[t], name+`.json`))
 	}
 	m.registry.Store(t, name, version)
 	return nil
@@ -302,9 +298,7 @@ func (m *Manager) Delete(t PluginType, name string, stop bool) error {
 	paths := []string{
 		path.Join(m.pluginDir, PluginTypes[t], soFile),
 	}
-	if confDir, err := common.GetConfLoc(); nil == err {
-		os.Remove(path.Join(confDir, PluginTypes[t], name+".json"))
-	}
+	os.Remove(path.Join(m.etcDir, PluginTypes[t], name+".json"))
 	if t == SOURCE {
 		paths = append(paths, path.Join(m.etcDir, PluginTypes[t], name+".yaml"))
 	}
@@ -389,14 +383,7 @@ func (m *Manager) install(t PluginType, name string, src string) ([]string, stri
 			}
 			filenames = append(filenames, yamlPath)
 		} else if fileName == name+".json" {
-			confDir, err := common.GetConfLoc()
-			if nil != err {
-				return filenames, "", err
-			}
-			err = unzipTo(file, path.Join(confDir, PluginTypes[t], fileName))
-			if err != nil {
-				return filenames, "", err
-			}
+			unzipTo(file, path.Join(m.etcDir, PluginTypes[t], fileName))
 		} else if soPrefix.Match([]byte(fileName)) {
 			soPath := path.Join(m.pluginDir, PluginTypes[t], fileName)
 			err = unzipTo(file, soPath)