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 DEFAULT_HARVESTER_NAME = 'harvester'
|
||||
local VERSION = "2.0.2"
|
||||
local VERSION = "2.0.3"
|
||||
local INFERIUM_SERVER = 'inferium.com'
|
||||
|
||||
local PERSISTED_CONFIGS = '/data/inferium-configs'
|
||||
@ -52,8 +52,11 @@ local function saveConfigForComputer(computerId, config)
|
||||
end
|
||||
|
||||
-- Utils
|
||||
|
||||
local function getConfigWithLength(config)
|
||||
if not config then
|
||||
return config
|
||||
end
|
||||
|
||||
local configWithLength = utils.shallowClone(config)
|
||||
configWithLength.length = utils.sizeof(config.plan)
|
||||
|
||||
|
||||
@ -41,10 +41,15 @@ utils.shallowDiff = function(a, b)
|
||||
end
|
||||
|
||||
utils.shallowClone = function(t)
|
||||
if not t then
|
||||
return t
|
||||
end
|
||||
|
||||
local res = {}
|
||||
for k,v in pairs(t) do
|
||||
res[k] = v
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user