@zenfs/core 0.16.4 → 0.17.1
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/dist/backends/backend.d.ts +3 -4
- package/dist/backends/fetch.d.ts +8 -3
- package/dist/backends/fetch.js +3 -2
- package/dist/backends/{index/fs.d.ts → file_index.d.ts} +49 -10
- package/dist/backends/{index/fs.js → file_index.js} +84 -5
- package/dist/backends/memory.d.ts +6 -1
- package/dist/backends/memory.js +2 -1
- package/dist/backends/overlay.d.ts +16 -16
- package/dist/backends/overlay.js +59 -82
- package/dist/backends/port/fs.d.ts +6 -2
- package/dist/backends/port/fs.js +4 -2
- package/dist/backends/store/fs.js +484 -304
- package/dist/backends/store/simple.js +5 -1
- package/dist/backends/store/store.d.ts +4 -1
- package/dist/backends/store/store.js +9 -5
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/config.d.ts +3 -3
- package/dist/emulation/async.d.ts +1 -4
- package/dist/emulation/async.js +9 -4
- package/dist/emulation/dir.d.ts +4 -0
- package/dist/emulation/dir.js +8 -6
- package/dist/emulation/promises.d.ts +1 -3
- package/dist/emulation/promises.js +25 -2
- package/dist/emulation/sync.js +0 -1
- package/dist/emulation/watchers.d.ts +9 -4
- package/dist/emulation/watchers.js +7 -0
- package/dist/file.d.ts +17 -1
- package/dist/file.js +86 -1
- package/dist/filesystem.d.ts +4 -67
- package/dist/filesystem.js +2 -313
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/mixins/async.d.ts +39 -0
- package/dist/mixins/async.js +216 -0
- package/dist/mixins/index.d.ts +4 -0
- package/dist/mixins/index.js +4 -0
- package/dist/mixins/mutexed.d.ts +33 -0
- package/dist/mixins/mutexed.js +465 -0
- package/dist/mixins/readonly.d.ts +25 -0
- package/dist/mixins/readonly.js +57 -0
- package/dist/mixins/shared.d.ts +12 -0
- package/dist/mixins/shared.js +4 -0
- package/dist/mixins/sync.d.ts +6 -0
- package/dist/mixins/sync.js +43 -0
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +0 -7
- package/package.json +3 -2
- package/src/backends/backend.ts +3 -4
- package/src/backends/fetch.ts +7 -3
- package/src/backends/{index/fs.ts → file_index.ts} +106 -8
- package/src/backends/memory.ts +5 -1
- package/src/backends/overlay.ts +64 -90
- package/src/backends/port/fs.ts +7 -2
- package/src/backends/{index/readme.md → readme.md} +1 -1
- package/src/backends/store/fs.ts +97 -155
- package/src/backends/store/simple.ts +5 -1
- package/src/backends/store/store.ts +10 -5
- package/src/config.ts +3 -1
- package/src/emulation/async.ts +20 -9
- package/src/emulation/dir.ts +19 -16
- package/src/emulation/promises.ts +28 -6
- package/src/emulation/sync.ts +1 -2
- package/src/emulation/watchers.ts +10 -4
- package/src/file.ts +94 -1
- package/src/filesystem.ts +5 -368
- package/src/index.ts +2 -2
- package/src/mixins/async.ts +211 -0
- package/src/mixins/index.ts +4 -0
- package/src/mixins/mutexed.ts +245 -0
- package/src/mixins/readonly.ts +97 -0
- package/src/mixins/shared.ts +20 -0
- package/src/mixins/sync.ts +59 -0
- package/src/utils.ts +0 -8
- package/dist/backends/index/index.d.ts +0 -43
- package/dist/backends/index/index.js +0 -83
- package/dist/backends/locked.d.ts +0 -92
- package/dist/backends/locked.js +0 -487
- package/src/backends/index/index.ts +0 -104
- package/src/backends/locked.ts +0 -264
|
@@ -69,9 +69,12 @@ export class SimpleTransaction extends SyncTransaction {
|
|
|
69
69
|
this.store.delete(ino);
|
|
70
70
|
}
|
|
71
71
|
commitSync() {
|
|
72
|
-
|
|
72
|
+
this.done = true;
|
|
73
73
|
}
|
|
74
74
|
abortSync() {
|
|
75
|
+
if (!this.done) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
75
78
|
// Rollback old values.
|
|
76
79
|
for (const key of this.modifiedKeys) {
|
|
77
80
|
const value = this.originalData.get(key);
|
|
@@ -84,6 +87,7 @@ export class SimpleTransaction extends SyncTransaction {
|
|
|
84
87
|
this.store.set(key, value);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
90
|
+
this.done = true;
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
93
|
* Stashes given key value pair into `originalData` if it doesn't already
|
|
@@ -31,7 +31,10 @@ export interface Store {
|
|
|
31
31
|
export declare abstract class Transaction<T extends Store = Store> {
|
|
32
32
|
protected store: T;
|
|
33
33
|
constructor(store: T);
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Whether the transaction was commited or aborted
|
|
36
|
+
*/
|
|
37
|
+
protected done: boolean;
|
|
35
38
|
/**
|
|
36
39
|
* Retrieves the data at the given key.
|
|
37
40
|
* @param ino The key to look under for data.
|
|
@@ -6,25 +6,29 @@ import '../../polyfills.js';
|
|
|
6
6
|
export class Transaction {
|
|
7
7
|
constructor(store) {
|
|
8
8
|
this.store = store;
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Whether the transaction was commited or aborted
|
|
11
|
+
*/
|
|
12
|
+
this.done = false;
|
|
10
13
|
}
|
|
11
14
|
async [Symbol.asyncDispose]() {
|
|
12
|
-
if (this.
|
|
15
|
+
if (this.done) {
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
|
-
await this.
|
|
18
|
+
await this.abort();
|
|
16
19
|
}
|
|
17
20
|
[Symbol.dispose]() {
|
|
18
|
-
if (this.
|
|
21
|
+
if (this.done) {
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
|
-
this.
|
|
24
|
+
this.abortSync();
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Transaction that implements asynchronous operations with synchronous ones
|
|
26
29
|
*/
|
|
27
30
|
export class SyncTransaction extends Transaction {
|
|
31
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
28
32
|
async get(ino) {
|
|
29
33
|
return this.getSync(ino);
|
|
30
34
|
}
|