Merge pull request #697 from andrasio/plugin-loadone

Load plugin if and only if it hasn't been registered.
This commit is contained in:
Andrés N. Robalino 2019-09-23 17:21:44 -05:00 committed by GitHub
commit c7b9db0523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,21 +72,23 @@ fn load_plugin(path: &std::path::Path, context: &mut Context) -> Result<(), Shel
trace!("processing {:?}", params);
if params.is_filter {
let fname = fname.to_string();
let name = params.name.clone();
context.add_commands(vec![whole_stream_command(PluginCommand::new(
name, fname, params,
))]);
Ok(())
let name = params.name.clone();
let fname = fname.to_string();
if context.has_command(&name) {
trace!("plugin {:?} already loaded.", &name);
} else {
let fname = fname.to_string();
let name = params.name.clone();
context.add_commands(vec![whole_stream_command(PluginSink::new(
name, fname, params,
))]);
Ok(())
if params.is_filter {
context.add_commands(vec![whole_stream_command(
PluginCommand::new(name, fname, params),
)]);
} else {
context.add_commands(vec![whole_stream_command(PluginSink::new(
name, fname, params,
))]);
};
}
Ok(())
}
Err(e) => Err(e),
},