Commit e66d40ca authored by Yann Leboulanger's avatar Yann Leboulanger

improve update_plugins function

parent 9ea9b4ad
Pipeline #2398 passed with stages
in 4 minutes and 29 seconds
......@@ -145,7 +145,8 @@ class PluginManager(metaclass=Singleton):
updated_plugins = []
user_dir = configpaths.get('PLUGINS_USER')
dl_dir = configpaths.get('PLUGINS_DOWNLOAD')
for directory in next(os.walk(dl_dir))[1]:
to_update = [plugin_name] if plugin_name else next(os.walk(dl_dir))[1]
for directory in to_update:
src_dir = os.path.join(dl_dir, directory)
dst_dir = os.path.join(user_dir, directory)
try:
......@@ -155,10 +156,13 @@ class PluginManager(metaclass=Singleton):
self.delete_plugin_files(dst_dir)
move(src_dir, dst_dir)
except Exception:
log.warning('Upgrade of plugin %s failed. Impossible to move files from "%s" to "%s"' % (directory, src_dir, dst_dir))
log.exception('Upgrade of plugin %s failed. Impossible to move '
'files from "%s" to "%s"', directory, src_dir, dst_dir)
continue
updated_plugins.append(directory)
if activate:
pc = self.scan_dir_for_plugins(dst_dir, scan_dirs=True, package=True)
pc = self.scan_dir_for_plugins(dst_dir, scan_dirs=True,
package=True)
self.add_plugin(pc[0])
plugin = self.plugins[-1]
self.activate_plugin(plugin)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment