@atomiqlabs/lp-lib 14.0.0-dev.3 → 14.0.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntermediaryStorageManager = void 0;
4
4
  const fs = require("fs/promises");
5
+ const fsSync = require("fs");
5
6
  const Utils_1 = require("../utils/Utils");
6
7
  class IntermediaryStorageManager {
7
8
  constructor(directory) {
@@ -86,6 +87,10 @@ class IntermediaryStorageManager {
86
87
  }
87
88
  async loadData(type) {
88
89
  this.type = type;
90
+ if (!fsSync.existsSync(this.directory)) {
91
+ this.logger.debug("loadData(): Data directory not found!");
92
+ return;
93
+ }
89
94
  let files;
90
95
  try {
91
96
  files = await fs.readdir(this.directory);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StorageManager = void 0;
4
4
  const fs = require("fs/promises");
5
5
  const Utils_1 = require("../utils/Utils");
6
+ const fs_1 = require("fs");
6
7
  class StorageManager {
7
8
  constructor(directory) {
8
9
  this.data = {};
@@ -36,6 +37,10 @@ class StorageManager {
36
37
  }
37
38
  }
38
39
  async loadData(type) {
40
+ if (!fs_1.default.existsSync(this.directory)) {
41
+ this.logger.debug("loadData(): Data directory not found!");
42
+ return;
43
+ }
39
44
  let files;
40
45
  try {
41
46
  files = await fs.readdir(this.directory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "14.0.0-dev.3",
3
+ "version": "14.0.0-dev.4",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import {StorageObject} from "@atomiqlabs/base";
2
2
  import * as fs from "fs/promises";
3
+ import * as fsSync from "fs";
3
4
  import {IIntermediaryStorage, StorageQueryParam} from "../storage/IIntermediaryStorage";
4
5
  import {getLogger, LoggerType} from "../utils/Utils";
5
6
 
@@ -92,6 +93,11 @@ export class IntermediaryStorageManager<T extends StorageObject> implements IInt
92
93
  async loadData(type: new(data: any) => T): Promise<void> {
93
94
  this.type = type;
94
95
 
96
+ if(!fsSync.existsSync(this.directory)) {
97
+ this.logger.debug("loadData(): Data directory not found!");
98
+ return;
99
+ }
100
+
95
101
  let files: string[];
96
102
  try {
97
103
  files = await fs.readdir(this.directory);
@@ -1,6 +1,7 @@
1
1
  import {StorageObject, IStorageManager} from "@atomiqlabs/base";
2
2
  import * as fs from "fs/promises";
3
3
  import {getLogger, LoggerType} from "../utils/Utils";
4
+ import fsSync from "fs";
4
5
 
5
6
  export class StorageManager<T extends StorageObject> implements IStorageManager<T> {
6
7
 
@@ -47,6 +48,11 @@ export class StorageManager<T extends StorageObject> implements IStorageManager<
47
48
  }
48
49
 
49
50
  async loadData(type: new(data: any) => T): Promise<T[]> {
51
+ if(!fsSync.existsSync(this.directory)) {
52
+ this.logger.debug("loadData(): Data directory not found!");
53
+ return;
54
+ }
55
+
50
56
  let files;
51
57
  try {
52
58
  files = await fs.readdir(this.directory);