mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Merge pull request #160 from YunoHost/close-conf-files
closing the files when we're done reading them
This commit is contained in:
commit
6bcf840f4d
1 changed files with 6 additions and 2 deletions
|
@ -11,14 +11,18 @@ function get_config()
|
||||||
-- Load the configuration file
|
-- Load the configuration file
|
||||||
local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing")
|
local conf_file = assert(io.open(conf_path, "r"), "Configuration file is missing")
|
||||||
local conf = json.decode(conf_file:read("*all"))
|
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.
|
-- Load additional rules from the `.persistent` configuration file.
|
||||||
-- The `.persistent` file contains rules that will overwrite previous rules.
|
-- The `.persistent` file contains rules that will overwrite previous rules.
|
||||||
-- It typically enables you to set custom rules.
|
-- It typically enables you to set custom rules.
|
||||||
local persistent_conf_file = io.open(conf_path..".persistent", "r")
|
local persistent_conf_file = io.open(conf_path..".persistent", "r")
|
||||||
if persistent_conf_file ~= nil then
|
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 the configuration key already exists and is a table, merge it
|
||||||
if conf[k] and type(v) == "table" then
|
if conf[k] and type(v) == "table" then
|
||||||
|
|
Loading…
Reference in a new issue