From 0b9f50246c10b7b58aff91f849ae3615e0fc2df6 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sun, 29 Mar 2020 19:39:25 +0200 Subject: [PATCH 1/2] closing the files when we're done reading them --- config.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config.lua b/config.lua index 1bf9151..d8f3ef4 100644 --- a/config.lua +++ b/config.lua @@ -11,14 +11,16 @@ function get_config() -- Load the configuration file local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing") local conf = json.decode(conf_file:read("*all")) - + conf_file:close() -- Load additional rules from the `.persistent` configuration file. -- The `.persistent` file contains rules that will overwrite previous rules. -- It typically enables you to set custom rules. local persistent_conf_file = io.open(conf_path..".persistent", "r") if persistent_conf_file ~= nil then - for k, v in pairs(json.decode(persistent_conf_file:read("*all"))) do + perm_conf = json.decode(persistent_conf_file:read("*all")) + persistent_conf_file:close() + for k, v in pairs(perm_conf) do -- If the configuration key already exists and is a table, merge it if conf[k] and type(v) == "table" then From 971cd1802cc1a1f4b36ce5ebd0e04b88b8e6b537 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Jul 2020 15:44:58 +0200 Subject: [PATCH 2/2] Update config.lua Co-authored-by: Kayou --- config.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.lua b/config.lua index d8f3ef4..90141f8 100644 --- a/config.lua +++ b/config.lua @@ -11,7 +11,9 @@ function get_config() -- Load the configuration file local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing") local conf = json.decode(conf_file:read("*all")) - conf_file:close() + if conf_file ~= nil then + conf_file:close() + end -- Load additional rules from the `.persistent` configuration file. -- The `.persistent` file contains rules that will overwrite previous rules.