From 21004ab183b1b099074856e4a4cb788ed84af9b1 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 21 May 2022 23:05:19 +0100 Subject: [PATCH] Tweak module loading to match new Rack 2.1.1 behaviour Signed-off-by: falkTX --- plugins/plugins.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/plugins.cpp b/plugins/plugins.cpp index 8ed6b8f..6b38d8c 100644 --- a/plugins/plugins.cpp +++ b/plugins/plugins.cpp @@ -821,13 +821,23 @@ struct StaticPluginLoader { json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str()); json_object_set(rootJ, "version", version); json_decref(version); + + // Load manifest + p->fromJson(rootJ); + + // Reject plugin if slug already exists + if (Plugin* const existingPlugin = getPlugin(p->slug)) + throw Exception("Plugin %s is already loaded, not attempting to load it again", p->slug.c_str()); } ~StaticPluginLoader() { if (rootJ != nullptr) { - plugin->fromJson(rootJ); + // Load modules manifest + json_t* const modulesJ = json_object_get(rootJ, "modules"); + plugin->modulesFromJson(modulesJ); + json_decref(rootJ); plugins.push_back(plugin); }