Tweak module loading to match new Rack 2.1.1 behaviour

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-05-21 23:05:19 +01:00
parent ed0a04a11c
commit 21004ab183
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0

View file

@ -821,13 +821,23 @@ struct StaticPluginLoader {
json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str()); json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str());
json_object_set(rootJ, "version", version); json_object_set(rootJ, "version", version);
json_decref(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() ~StaticPluginLoader()
{ {
if (rootJ != nullptr) if (rootJ != nullptr)
{ {
plugin->fromJson(rootJ); // Load modules manifest
json_t* const modulesJ = json_object_get(rootJ, "modules");
plugin->modulesFromJson(modulesJ);
json_decref(rootJ); json_decref(rootJ);
plugins.push_back(plugin); plugins.push_back(plugin);
} }