X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FJSONFileStorage.ts;h=25ba236703f4b60393b963fa0f349b7c01ea9b9d;hb=a6ceb16a6b67653adaa0b40cd057826c71f44f36;hp=cc7920a0a4aadfe40ffb6710dddf0e012f1ea9ed;hpb=d09085e9e6ec32bb1873b8f4cc1b326f7996d0f3;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; }