From 019f13fe8dd09d3747a257e7e229338bcd49cf54 Mon Sep 17 00:00:00 2001 From: Arinerron Date: Sun, 13 May 2018 21:22:28 -0700 Subject: [PATCH] Fix bug involving plugin duplicate names --- onionr/onionrplugins.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/onionr/onionrplugins.py b/onionr/onionrplugins.py index bdb7a073..175b2336 100644 --- a/onionr/onionrplugins.py +++ b/onionr/onionrplugins.py @@ -62,17 +62,20 @@ def enable(name, onionr = None, start_event = True): if exists(name): enabled_plugins = get_enabled_plugins() - enabled_plugins.append(name) - config_plugins = config.get('plugins') - config_plugins['enabled'] = enabled_plugins - config.set('plugins', config_plugins, True) + if not name in enabled_plugins: + enabled_plugins.append(name) + config_plugins = config.get('plugins') + config_plugins['enabled'] = enabled_plugins + config.set('plugins', config_plugins, True) - events.call(get_plugin(name), 'enable', onionr) + events.call(get_plugin(name), 'enable', onionr) - if start_event is True: - start(name) + if start_event is True: + start(name) - return True + return True + else: + return False else: logger.error('Failed to enable plugin \"' + name + '\", disabling plugin.') disable(name)