Merge pull request #160 from YunoHost/close-conf-files

closing the files when we're done reading them
This commit is contained in:
Alexandre Aubin 2020-07-27 15:45:23 +02:00 committed by GitHub
commit 6bcf840f4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,14 +11,18 @@ 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"))
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.
-- 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