config default set utility

This commit is contained in:
2026-09-17 01:56:35 -06:00
parent 77298dad0c
commit dd9ca71fc7
2 changed files with 31 additions and 10 deletions
+26 -2
View File
@@ -375,10 +375,10 @@ end
local config_path = utility.path .. "config.json"
local config, config_lock
utility.get_config = function(skip_lock)
if not config then
local config_path = utility.path .. "config.json"
if utility.is_file(config_path) then
if not skip_lock then
config_lock = utility.get_lock(config_path)
@@ -396,7 +396,6 @@ end
utility.save_config = function()
if config then
local config_path = utility.path .. "config.json"
if not config_lock then
print("Warning: A config lock file was not established.")
end
@@ -412,6 +411,31 @@ utility.save_config = function()
end
end
utility.get_config_with_defaults = function(defaults)
local config = utility.get_config()
local loop, changes_made
loop = function(config_level, default_level)
for k,v in pairs(default_level) do
if not config_level[k] then
config_level[k] = v
changes_made = true
elseif type(v) == "table" then
loop(config_level[k], v)
end
end
end
loop(config, defaults)
if changes_made then
utility.save_config()
else
utility.release_lock(config_path)
end
return config
end
local data_file_locations = {}