// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
import fs from 'node:fs';
+import path from 'node:path';
+import { Storage } from './Storage';
import { FileType, type Statistics } from '../../types';
import { AsyncLock, AsyncLockType, Constants, FileUtils, Utils } from '../../utils';
-import { Storage } from '../internal';
export class JsonFileStorage extends Storage {
private fd: number | null = null;
public open(): void {
try {
if (Utils.isNullOrUndefined(this?.fd)) {
+ if (!fs.existsSync(path.dirname(this.dbName))) {
+ fs.mkdirSync(path.dirname(this.dbName), { recursive: true });
+ }
this.fd = fs.openSync(this.dbName, 'a+');
}
} catch (error) {