fix(inferium-server): crash with shallowClone when a config does not exist

This commit is contained in:
Guillaume ARM 2024-05-22 21:39:06 +02:00
parent 9e09ac85c3
commit 30c1da50e5
2 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -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