From 05dcddaeece0ca39cad2b5e093de4a9317b77923 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 7 Nov 2021 13:14:48 -0500 Subject: [PATCH] Made plugin load order deterministic. --- data/core/init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 6ef0ab7e..6dd54cd4 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -675,16 +675,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