@zenfs/core 0.12.8 → 0.12.9

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.
@@ -33,6 +33,8 @@ export const InMemory = {
33
33
  },
34
34
  },
35
35
  create({ name }) {
36
- return new StoreFS(new InMemoryStore(name));
36
+ const fs = new StoreFS(new InMemoryStore(name));
37
+ fs.checkRootSync();
38
+ return fs;
37
39
  },
38
40
  };
@@ -62,11 +62,11 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
62
62
  /**
63
63
  * Checks if the root directory exists. Creates it if it doesn't.
64
64
  */
65
- private makeRootDirectory;
65
+ checkRoot(): Promise<void>;
66
66
  /**
67
67
  * Checks if the root directory exists. Creates it if it doesn't.
68
68
  */
69
- protected makeRootDirectorySync(): void;
69
+ checkRootSync(): void;
70
70
  /**
71
71
  * Helper function for findINode.
72
72
  * @param parent The parent directory of the file we are attempting to find.
@@ -20,17 +20,13 @@ export class StoreFS extends FileSystem {
20
20
  if (this._initialized) {
21
21
  return;
22
22
  }
23
- await this.makeRootDirectory();
23
+ await this.checkRoot();
24
24
  this._initialized = true;
25
25
  }
26
26
  constructor(store) {
27
27
  super();
28
28
  this.store = store;
29
29
  this._initialized = false;
30
- if (!this._disableSync) {
31
- this.makeRootDirectorySync();
32
- this._initialized = true;
33
- }
34
30
  }
35
31
  metadata() {
36
32
  return {
@@ -45,7 +41,7 @@ export class StoreFS extends FileSystem {
45
41
  async empty() {
46
42
  await this.store.clear();
47
43
  // Root always exists.
48
- await this.makeRootDirectory();
44
+ await this.checkRoot();
49
45
  }
50
46
  /**
51
47
  * Delete all contents stored in the file system.
@@ -54,7 +50,7 @@ export class StoreFS extends FileSystem {
54
50
  emptySync() {
55
51
  this.store.clearSync();
56
52
  // Root always exists.
57
- this.makeRootDirectorySync();
53
+ this.checkRootSync();
58
54
  }
59
55
  /**
60
56
  * @todo Make rename compatible with the cache.
@@ -375,7 +371,7 @@ export class StoreFS extends FileSystem {
375
371
  /**
376
372
  * Checks if the root directory exists. Creates it if it doesn't.
377
373
  */
378
- async makeRootDirectory() {
374
+ async checkRoot() {
379
375
  const tx = this.store.transaction();
380
376
  if (await tx.get(rootIno)) {
381
377
  return;
@@ -391,7 +387,7 @@ export class StoreFS extends FileSystem {
391
387
  /**
392
388
  * Checks if the root directory exists. Creates it if it doesn't.
393
389
  */
394
- makeRootDirectorySync() {
390
+ checkRootSync() {
395
391
  const tx = this.store.transaction();
396
392
  if (tx.getSync(rootIno)) {
397
393
  return;