fix(inferium-server): crash with shallowClone when a config does not exist
This commit is contained in:
parent
9e09ac85c3
commit
30c1da50e5
@ -3,7 +3,7 @@ local utils = require('libs/utils')
|
|||||||
local inferium = require('config/inferium')
|
local inferium = require('config/inferium')
|
||||||
|
|
||||||
local DEFAULT_HARVESTER_NAME = 'harvester'
|
local DEFAULT_HARVESTER_NAME = 'harvester'
|
||||||
local VERSION = "2.0.2"
|
local VERSION = "2.0.3"
|
||||||
local INFERIUM_SERVER = 'inferium.com'
|
local INFERIUM_SERVER = 'inferium.com'
|
||||||
|
|
||||||
local PERSISTED_CONFIGS = '/data/inferium-configs'
|
local PERSISTED_CONFIGS = '/data/inferium-configs'
|
||||||
@ -52,8 +52,11 @@ local function saveConfigForComputer(computerId, config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Utils
|
-- Utils
|
||||||
|
|
||||||
local function getConfigWithLength(config)
|
local function getConfigWithLength(config)
|
||||||
|
if not config then
|
||||||
|
return config
|
||||||
|
end
|
||||||
|
|
||||||
local configWithLength = utils.shallowClone(config)
|
local configWithLength = utils.shallowClone(config)
|
||||||
configWithLength.length = utils.sizeof(config.plan)
|
configWithLength.length = utils.sizeof(config.plan)
|
||||||
|
|
||||||
|
|||||||
@ -41,10 +41,15 @@ utils.shallowDiff = function(a, b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
utils.shallowClone = function(t)
|
utils.shallowClone = function(t)
|
||||||
|
if not t then
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
local res = {}
|
local res = {}
|
||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
res[k] = v
|
res[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user