Fix config.lua crash: move _configPath before first use
_configPath was called at lines 26/28 (CACHE_FILE, DISABLED_RECIPES_FILE) but only defined at line 79. Moved the definition to the top of the function body so it exists before the first call.
This commit is contained in:
@@ -6,6 +6,16 @@ return function(log, _path)
|
|||||||
-- Fall back to CWD-relative if _path not provided (standalone use)
|
-- Fall back to CWD-relative if _path not provided (standalone use)
|
||||||
if not _path then _path = function(p) return p end end
|
if not _path then _path = function(p) return p end end
|
||||||
|
|
||||||
|
-- Persistent config path: survives Opus package updates
|
||||||
|
local _PERSIST_DIR = "usr/config/inventory-manager"
|
||||||
|
local function _configPath(rel)
|
||||||
|
if fs.isDir(_PERSIST_DIR) or fs.isDir("packages/inventory-manager") then
|
||||||
|
if not fs.isDir(_PERSIST_DIR) then fs.makeDir(_PERSIST_DIR) end
|
||||||
|
return fs.combine(_PERSIST_DIR, rel)
|
||||||
|
end
|
||||||
|
return _path(rel)
|
||||||
|
end
|
||||||
|
|
||||||
local C = {}
|
local C = {}
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
@@ -71,16 +81,6 @@ C.SLOT_OUTPUT = 3
|
|||||||
-- Config file loader
|
-- Config file loader
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
-- Persistent config path: survives Opus package updates
|
|
||||||
local _PERSIST_DIR = "usr/config/inventory-manager"
|
|
||||||
local function _configPath(rel)
|
|
||||||
if fs.isDir(_PERSIST_DIR) or fs.isDir("packages/inventory-manager") then
|
|
||||||
if not fs.isDir(_PERSIST_DIR) then fs.makeDir(_PERSIST_DIR) end
|
|
||||||
return fs.combine(_PERSIST_DIR, rel)
|
|
||||||
end
|
|
||||||
return _path(rel)
|
|
||||||
end
|
|
||||||
|
|
||||||
local CONFIG_FILE = _configPath(".manager_config")
|
local CONFIG_FILE = _configPath(".manager_config")
|
||||||
|
|
||||||
function C.loadConfig()
|
function C.loadConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user