closing the files when we're done reading them

This commit is contained in:
Kay0u 2020-03-29 19:39:25 +02:00
parent 8cc2bd4b28
commit 0b9f50246c
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156

View file

@ -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