From 6536352d531e9c6602c59e909c88146d089e2732 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 13 Nov 2018 16:17:15 +0000 Subject: [PATCH] [Fix] Fix override_defaults function --- lualib/lua_fuzzy.lua | 1 + lualib/lua_util.lua | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua index 178d06400..bd601c038 100644 --- a/lualib/lua_fuzzy.lua +++ b/lualib/lua_fuzzy.lua @@ -262,6 +262,7 @@ local function mime_types_check(task, part, rule) end if rule.mime_types then + if fun.any(function(gl_re) if gl_re:match(ct) then return true else return false end end, rule.mime_types) then diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index 276b8e05a..8611946a1 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -520,7 +520,8 @@ local function override_defaults(def, override) end local res = {} - fun.each(function(k, v) + + for k,v in pairs(override) do if type(v) == 'table' then if def[k] and type(def[k]) == 'table' then -- Recursively override elements @@ -531,12 +532,13 @@ local function override_defaults(def, override) else res[k] = v end - end, override) - fun.each(function(k, v) + end + + for k,v in pairs(def) do if not res[k] then res[k] = v end - end, def) + end return res end -- 2.39.5