Made plugin load order deterministic.

This commit is contained in:
Adam Harrison 2021-11-07 13:14:48 -05:00 committed by Guldoman
parent 43a6e21135
commit 20f0c5ba1e
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 5 additions and 3 deletions

View File

@ -871,16 +871,18 @@ function core.load_plugins()
userdir = {dir = USERDIR, plugins = {}},
datadir = {dir = DATADIR, plugins = {}},
}
local files = {}
local files, ordered = {}, {}
for _, root_dir in ipairs {DATADIR, USERDIR} do
local plugin_dir = root_dir .. "/plugins"
for _, filename in ipairs(system.list_dir(plugin_dir) or {}) do
if not files[filename] then table.insert(ordered, filename) end
files[filename] = plugin_dir -- user plugins will always replace system plugins
end
end
table.sort(ordered)
for filename, plugin_dir in pairs(files) do
local basename = filename:match("(.-)%.lua$") or filename
for i, filename in ipairs(ordered) do
local plugin_dir, basename = files[filename], filename:match("(.-)%.lua$") or filename
local is_lua_file, version_match = check_plugin_version(plugin_dir .. '/' .. filename)
if is_lua_file then
if not version_match then