directories should not be loaded

This commit is contained in:
lqdev 2021-04-25 11:45:08 +02:00
parent 58422271ce
commit 5e8e2f54b5
1 changed files with 16 additions and 13 deletions

View File

@ -625,19 +625,22 @@ function core.load_plugins()
local plugin_dir = root_dir .. "/plugins" local plugin_dir = root_dir .. "/plugins"
local files = system.list_dir(plugin_dir) local files = system.list_dir(plugin_dir)
for _, filename in ipairs(files or {}) do for _, filename in ipairs(files or {}) do
local basename = filename:match("(.-)%.lua$") or filename local info = system.get_file_info(filename)
local version_match = check_plugin_version(plugin_dir .. '/' .. filename) if info ~= nil and info.type == "file" then
if not version_match then local basename = filename:match("(.-)%.lua$") or filename
core.log_quiet("Version mismatch for plugin %q from %s", basename, plugin_dir) local version_match = check_plugin_version(plugin_dir .. '/' .. filename)
local ls = refused_list[root_dir == USERDIR and 'userdir' or 'datadir'].plugins if not version_match then
ls[#ls + 1] = filename core.log_quiet("Version mismatch for plugin %q from %s", basename, plugin_dir)
end local ls = refused_list[root_dir == USERDIR and 'userdir' or 'datadir'].plugins
if version_match and config[basename] ~= false then ls[#ls + 1] = filename
local modname = "plugins." .. basename end
local ok = core.try(require, modname) if version_match and config[basename] ~= false then
if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end local modname = "plugins." .. basename
if not ok then local ok = core.try(require, modname)
no_errors = false if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end
if not ok then
no_errors = false
end
end end
end end
end end