PluginLoader: use directory name for enabled/disabled, deprecate metadata name

Presumably fairly similar to <https://github.com/OGKevin/koreader/commit/20ff60da3e7a776ce953e41e6912fe3eee3aa3ce> given the similar goal.
This commit is contained in:
Frans de Jonge authored and Frans de Jonge committed 2026-04-05 21:52:53 +02:00
1 parent 42bc2af95a
commit eb6fb1d7d3
2 files changed
+171 -6

No files matched your search

+9 -6
View File
@@ -14,7 +14,6 @@ Plugins are controlled by the following settings.
local dbg = require("dbg")
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
local util = require("util")
local _ = require("gettext")
local DEFAULT_PLUGIN_PATH = "plugins"
@@ -166,19 +165,19 @@ function PluginLoader:_discover()
if mode == "directory" and entry:sub(-9) == ".koplugin" then
local mainfile = plugin_root.."/main.lua"
local metafile = plugin_root.."/_meta.lua"
local plugin_name = entry:sub(1, -10)
local disabled = false
if plugins_disabled and plugins_disabled[entry:sub(1, -10)] then
if plugins_disabled and plugins_disabled[plugin_name] then
mainfile = metafile
disabled = true
end
local __, name = util.splitFilePathName(plugin_root)
table.insert(discovered, {
["main"] = mainfile,
["meta"] = metafile,
["path"] = plugin_root,
["disabled"] = disabled,
["name"] = name,
["name"] = plugin_name,
})
end
end
@@ -204,14 +203,18 @@ function PluginLoader:_load(t)
logger.warn("Error when loading", mainfile, plugin_module)
elseif type(plugin_module.disabled) ~= "boolean" or not plugin_module.disabled then
plugin_module.path = plugin_root
plugin_module.name = plugin_module.name or plugin_root:match("/(.-)%.koplugin")
plugin_module.name = v.name
if disabled then
table.insert(self.disabled_plugins, plugin_module)
else
local ok_meta, plugin_metamodule = pcall(dofile, metafile)
if ok_meta and plugin_metamodule then
for k, module in pairs(plugin_metamodule) do
plugin_module[k] = module
if k ~= "name" then
plugin_module[k] = module
else
logger.warn("PluginLoader:", plugin_module.name, "name in _meta.lua, is deprecated and will be ignored.")
end
end
end
sandboxPluginEventHandlers(plugin_module)