@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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9",
|
|
4
4
|
"description": "A filesystem in your browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
"make-index": "scripts/make-index.js",
|
|
14
14
|
"build": "scripts/build.js"
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"license.md",
|
|
20
|
+
"tsconfig.json"
|
|
21
|
+
],
|
|
16
22
|
"type": "module",
|
|
17
23
|
"homepage": "https://github.com/zen-fs/core",
|
|
18
24
|
"author": "James P. <jp@drvortex.dev> (https://drvortex.dev)",
|
|
@@ -39,7 +45,7 @@
|
|
|
39
45
|
"format": "prettier --write .",
|
|
40
46
|
"format:check": "prettier --check .",
|
|
41
47
|
"lint": "tsc -p tsconfig.json --noEmit && eslint src tests",
|
|
42
|
-
"test": "
|
|
48
|
+
"test": "tsc -p tests/tsconfig.json && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
|
|
43
49
|
"build": "node scripts/build.js --globalName=ZenFS --entry src/index.ts",
|
|
44
50
|
"build:docs": "typedoc --out docs --name ZenFS src/index.ts",
|
|
45
51
|
"dev": "npm run build -- --watch",
|
package/src/backends/memory.ts
CHANGED
|
@@ -39,6 +39,8 @@ export const InMemory = {
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
create({ name }: { name?: string }) {
|
|
42
|
-
|
|
42
|
+
const fs = new StoreFS(new InMemoryStore(name));
|
|
43
|
+
fs.checkRootSync();
|
|
44
|
+
return fs;
|
|
43
45
|
},
|
|
44
46
|
} as const satisfies Backend<StoreFS<InMemoryStore>, { name?: string }>;
|
package/src/backends/store/fs.ts
CHANGED
|
@@ -26,16 +26,12 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
26
26
|
if (this._initialized) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
await this.
|
|
29
|
+
await this.checkRoot();
|
|
30
30
|
this._initialized = true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
constructor(protected store: T) {
|
|
34
34
|
super();
|
|
35
|
-
if (!this._disableSync) {
|
|
36
|
-
this.makeRootDirectorySync();
|
|
37
|
-
this._initialized = true;
|
|
38
|
-
}
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
public metadata(): FileSystemMetadata {
|
|
@@ -52,7 +48,7 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
52
48
|
public async empty(): Promise<void> {
|
|
53
49
|
await this.store.clear();
|
|
54
50
|
// Root always exists.
|
|
55
|
-
await this.
|
|
51
|
+
await this.checkRoot();
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
/**
|
|
@@ -62,7 +58,7 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
62
58
|
public emptySync(): void {
|
|
63
59
|
this.store.clearSync();
|
|
64
60
|
// Root always exists.
|
|
65
|
-
this.
|
|
61
|
+
this.checkRootSync();
|
|
66
62
|
}
|
|
67
63
|
|
|
68
64
|
/**
|
|
@@ -444,7 +440,7 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
444
440
|
/**
|
|
445
441
|
* Checks if the root directory exists. Creates it if it doesn't.
|
|
446
442
|
*/
|
|
447
|
-
|
|
443
|
+
public async checkRoot(): Promise<void> {
|
|
448
444
|
const tx = this.store.transaction();
|
|
449
445
|
if (await tx.get(rootIno)) {
|
|
450
446
|
return;
|
|
@@ -461,7 +457,7 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
461
457
|
/**
|
|
462
458
|
* Checks if the root directory exists. Creates it if it doesn't.
|
|
463
459
|
*/
|
|
464
|
-
|
|
460
|
+
public checkRootSync(): void {
|
|
465
461
|
const tx = this.store.transaction();
|
|
466
462
|
if (tx.getSync(rootIno)) {
|
|
467
463
|
return;
|