From: Jérôme Benoit Date: Mon, 20 Feb 2023 20:16:51 +0000 (+0100) Subject: fix(simulator): clone configuration object before saving it X-Git-Tag: v1.1.95~38 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=648512ce52952784ed04fb714fd02311506f8b14;p=e-mobility-charging-stations-simulator.git fix(simulator): clone configuration object before saving it Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 27935e12..23724e79 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1362,7 +1362,7 @@ export class ChargingStation { fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true }); } const configurationData: ChargingStationConfiguration = - this.getConfigurationFromFile() ?? {}; + Utils.cloneObject(this.getConfigurationFromFile()) ?? {}; this.ocppConfiguration?.configurationKey && (configurationData.configurationKey = this.ocppConfiguration.configurationKey); this.stationInfo && (configurationData.stationInfo = this.stationInfo); @@ -1414,7 +1414,10 @@ export class ChargingStation { const configurationFromFile = this.getConfigurationFromFile(); configuration = configurationFromFile?.configurationKey && configurationFromFile; } - configuration && delete configuration.stationInfo; + if (!Utils.isNullOrUndefined(configuration)) { + delete configuration.stationInfo; + delete configuration.configurationHash; + } return configuration; }