X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FJSONFileStorage.ts;h=25ba236703f4b60393b963fa0f349b7c01ea9b9d;hb=a6ceb16a6b67653adaa0b40cd057826c71f44f36;hp=cc7920a0a4aadfe40ffb6710dddf0e012f1ea9ed;hpb=a6b3c6c313f1c0314a1445ed630cac85edf55b2c;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/storage/JSONFileStorage.ts b/src/performance/storage/JSONFileStorage.ts index cc7920a0..25ba2367 100644 --- a/src/performance/storage/JSONFileStorage.ts +++ b/src/performance/storage/JSONFileStorage.ts @@ -33,7 +33,9 @@ export class JSONFileStorage extends Storage { public open(): void { try { - this.fd = fs.openSync(this.dbName, 'a+'); + if (!this?.fd) { + this.fd = fs.openSync(this.dbName, 'a+'); + } } catch (error) { FileUtils.handleFileException(this.logPrefix, Constants.PERFORMANCE_RECORDS_FILETYPE, this.dbName, error); } @@ -41,7 +43,7 @@ export class JSONFileStorage extends Storage { public close(): void { try { - if (this.fd) { + if (this?.fd) { fs.closeSync(this.fd); this.fd = null; }