fix(simulator): clone configuration object before saving it
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Feb 2023 20:16:51 +0000 (21:16 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Feb 2023 20:16:51 +0000 (21:16 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 27935e12b809308fe87b00a781c896a9046b49df..23724e79014584cdf9d5dc042cd29b0fcce0f249 100644 (file)
@@ -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;
   }