fix(inferium-server): do not consider new harvester if a computer id is given

This commit is contained in:
Guillaume ARM 2024-05-22 21:31:47 +02:00
parent a28ccbc920
commit dd79ecb941

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.0"
local VERSION = "2.0.1"
local INFERIUM_SERVER = 'inferium.com'
local PERSISTED_CONFIGS = '/data/inferium-configs'
@ -76,15 +76,18 @@ end
-- Routes
local function getConfig(_, computerId)
local function getConfig(message, computerId)
if not computerId == nil then
print('get-config error: no computerId found')
return nil
end
local config = getConfigForComputer(computerId)
local givenHarvesterId = message and message.payload and message.payload.id
if not config then
local id = givenHarvesterId or computerId
local config = getConfigForComputer(id)
if not givenHarvesterId and not config then
print('new harvester detected: ' .. tostring(computerId))
saveConfigForComputer(computerId, defaultConfig)
config = defaultConfig