@zenfs/core 0.16.3 → 0.17.0
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 +0 -3
- package/dist/emulation/async.js +6 -2
- 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 +26 -3
- package/dist/emulation/sync.js +1 -2
- 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 +0 -63
- package/dist/filesystem.js +0 -311
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/mixins/async.d.ts +39 -0
- package/dist/mixins/async.js +216 -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/package.json +1 -1
- 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 +15 -6
- package/src/emulation/dir.ts +19 -16
- package/src/emulation/promises.ts +30 -8
- package/src/emulation/sync.ts +2 -3
- package/src/emulation/watchers.ts +10 -4
- package/src/file.ts +94 -1
- package/src/filesystem.ts +3 -366
- package/src/index.ts +1 -2
- package/src/mixins/async.ts +211 -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/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
package/dist/backends/overlay.js
CHANGED
|
@@ -2,7 +2,7 @@ import { FileSystem } from '../filesystem.js';
|
|
|
2
2
|
import { ErrnoError, Errno } from '../error.js';
|
|
3
3
|
import { PreloadFile, parseFlag } from '../file.js';
|
|
4
4
|
import { Stats } from '../stats.js';
|
|
5
|
-
import {
|
|
5
|
+
import { Mutexed } from '../mixins/mutexed.js';
|
|
6
6
|
import { dirname } from '../emulation/path.js';
|
|
7
7
|
import { rootCred } from '../cred.js';
|
|
8
8
|
import { decode, encode } from '../utils.js';
|
|
@@ -14,14 +14,14 @@ const deletionLogPath = '/.deleted';
|
|
|
14
14
|
* OverlayFS makes a read-only filesystem writable by storing writes on a second, writable file system.
|
|
15
15
|
* Deletes are persisted via metadata stored on the writable file system.
|
|
16
16
|
*
|
|
17
|
-
* This class contains no locking whatsoever. It is
|
|
17
|
+
* This class contains no locking whatsoever. It is mutexed to prevent races.
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
export class
|
|
21
|
+
export class UnmutexedOverlayFS extends FileSystem {
|
|
22
22
|
async ready() {
|
|
23
|
-
await this.
|
|
24
|
-
await this.
|
|
23
|
+
await this.readable.ready();
|
|
24
|
+
await this.writable.ready();
|
|
25
25
|
await this._ready;
|
|
26
26
|
}
|
|
27
27
|
constructor({ writable, readable }) {
|
|
@@ -34,9 +34,9 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
34
34
|
// If 'true', a delete log update is needed after the scheduled delete log
|
|
35
35
|
// update finishes.
|
|
36
36
|
this._deleteLogUpdateNeeded = false;
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
if (this.
|
|
37
|
+
this.writable = writable;
|
|
38
|
+
this.readable = readable;
|
|
39
|
+
if (this.writable.metadata().readonly) {
|
|
40
40
|
throw new ErrnoError(Errno.EINVAL, 'Writable file system must be writable.');
|
|
41
41
|
}
|
|
42
42
|
this._ready = this._initialize();
|
|
@@ -47,24 +47,18 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
47
47
|
name: OverlayFS.name,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
getOverlayedFileSystems() {
|
|
51
|
-
return {
|
|
52
|
-
readable: this._readable,
|
|
53
|
-
writable: this._writable,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
50
|
async sync(path, data, stats) {
|
|
57
51
|
const cred = stats.cred(0, 0);
|
|
58
52
|
await this.createParentDirectories(path, cred);
|
|
59
|
-
if (!(await this.
|
|
60
|
-
await this.
|
|
53
|
+
if (!(await this.writable.exists(path, cred))) {
|
|
54
|
+
await this.writable.createFile(path, 'w', 0o644, cred);
|
|
61
55
|
}
|
|
62
|
-
await this.
|
|
56
|
+
await this.writable.sync(path, data, stats);
|
|
63
57
|
}
|
|
64
58
|
syncSync(path, data, stats) {
|
|
65
59
|
const cred = stats.cred(0, 0);
|
|
66
60
|
this.createParentDirectoriesSync(path, cred);
|
|
67
|
-
this.
|
|
61
|
+
this.writable.syncSync(path, data, stats);
|
|
68
62
|
}
|
|
69
63
|
/**
|
|
70
64
|
* Called once to load up metadata stored on the writable file system.
|
|
@@ -76,7 +70,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
76
70
|
}
|
|
77
71
|
// Read deletion log, process into metadata.
|
|
78
72
|
try {
|
|
79
|
-
const file = await this.
|
|
73
|
+
const file = await this.writable.openFile(deletionLogPath, parseFlag('r'), rootCred);
|
|
80
74
|
const { size } = await file.stat();
|
|
81
75
|
const { buffer } = await file.read(new Uint8Array(size));
|
|
82
76
|
this._deleteLog = decode(buffer);
|
|
@@ -102,7 +96,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
102
96
|
this.checkPath(oldPath);
|
|
103
97
|
this.checkPath(newPath);
|
|
104
98
|
try {
|
|
105
|
-
await this.
|
|
99
|
+
await this.writable.rename(oldPath, newPath, cred);
|
|
106
100
|
}
|
|
107
101
|
catch (e) {
|
|
108
102
|
if (this._deletedFiles.has(oldPath)) {
|
|
@@ -115,7 +109,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
115
109
|
this.checkPath(oldPath);
|
|
116
110
|
this.checkPath(newPath);
|
|
117
111
|
try {
|
|
118
|
-
this.
|
|
112
|
+
this.writable.renameSync(oldPath, newPath, cred);
|
|
119
113
|
}
|
|
120
114
|
catch (e) {
|
|
121
115
|
if (this._deletedFiles.has(oldPath)) {
|
|
@@ -126,13 +120,13 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
126
120
|
async stat(path, cred) {
|
|
127
121
|
this.checkInitialized();
|
|
128
122
|
try {
|
|
129
|
-
return await this.
|
|
123
|
+
return await this.writable.stat(path, cred);
|
|
130
124
|
}
|
|
131
125
|
catch (e) {
|
|
132
126
|
if (this._deletedFiles.has(path)) {
|
|
133
127
|
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
134
128
|
}
|
|
135
|
-
const oldStat = new Stats(await this.
|
|
129
|
+
const oldStat = new Stats(await this.readable.stat(path, cred));
|
|
136
130
|
// Make the oldStat's mode writable. Preserve the topmost part of the mode, which specifies the type
|
|
137
131
|
oldStat.mode |= 0o222;
|
|
138
132
|
return oldStat;
|
|
@@ -141,34 +135,34 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
141
135
|
statSync(path, cred) {
|
|
142
136
|
this.checkInitialized();
|
|
143
137
|
try {
|
|
144
|
-
return this.
|
|
138
|
+
return this.writable.statSync(path, cred);
|
|
145
139
|
}
|
|
146
140
|
catch (e) {
|
|
147
141
|
if (this._deletedFiles.has(path)) {
|
|
148
142
|
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
149
143
|
}
|
|
150
|
-
const oldStat = new Stats(this.
|
|
144
|
+
const oldStat = new Stats(this.readable.statSync(path, cred));
|
|
151
145
|
// Make the oldStat's mode writable. Preserve the topmost part of the mode, which specifies the type.
|
|
152
146
|
oldStat.mode |= 0o222;
|
|
153
147
|
return oldStat;
|
|
154
148
|
}
|
|
155
149
|
}
|
|
156
150
|
async openFile(path, flag, cred) {
|
|
157
|
-
if (await this.
|
|
158
|
-
return this.
|
|
151
|
+
if (await this.writable.exists(path, cred)) {
|
|
152
|
+
return this.writable.openFile(path, flag, cred);
|
|
159
153
|
}
|
|
160
154
|
// Create an OverlayFile.
|
|
161
|
-
const file = await this.
|
|
155
|
+
const file = await this.readable.openFile(path, parseFlag('r'), cred);
|
|
162
156
|
const stats = new Stats(await file.stat());
|
|
163
157
|
const { buffer } = await file.read(new Uint8Array(stats.size));
|
|
164
158
|
return new PreloadFile(this, path, flag, stats, buffer);
|
|
165
159
|
}
|
|
166
160
|
openFileSync(path, flag, cred) {
|
|
167
|
-
if (this.
|
|
168
|
-
return this.
|
|
161
|
+
if (this.writable.existsSync(path, cred)) {
|
|
162
|
+
return this.writable.openFileSync(path, flag, cred);
|
|
169
163
|
}
|
|
170
164
|
// Create an OverlayFile.
|
|
171
|
-
const file = this.
|
|
165
|
+
const file = this.readable.openFileSync(path, parseFlag('r'), cred);
|
|
172
166
|
const stats = new Stats(file.statSync());
|
|
173
167
|
const data = new Uint8Array(stats.size);
|
|
174
168
|
file.readSync(data);
|
|
@@ -176,21 +170,21 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
176
170
|
}
|
|
177
171
|
async createFile(path, flag, mode, cred) {
|
|
178
172
|
this.checkInitialized();
|
|
179
|
-
await this.
|
|
173
|
+
await this.writable.createFile(path, flag, mode, cred);
|
|
180
174
|
return this.openFile(path, flag, cred);
|
|
181
175
|
}
|
|
182
176
|
createFileSync(path, flag, mode, cred) {
|
|
183
177
|
this.checkInitialized();
|
|
184
|
-
this.
|
|
178
|
+
this.writable.createFileSync(path, flag, mode, cred);
|
|
185
179
|
return this.openFileSync(path, flag, cred);
|
|
186
180
|
}
|
|
187
181
|
async link(srcpath, dstpath, cred) {
|
|
188
182
|
this.checkInitialized();
|
|
189
|
-
await this.
|
|
183
|
+
await this.writable.link(srcpath, dstpath, cred);
|
|
190
184
|
}
|
|
191
185
|
linkSync(srcpath, dstpath, cred) {
|
|
192
186
|
this.checkInitialized();
|
|
193
|
-
this.
|
|
187
|
+
this.writable.linkSync(srcpath, dstpath, cred);
|
|
194
188
|
}
|
|
195
189
|
async unlink(path, cred) {
|
|
196
190
|
this.checkInitialized();
|
|
@@ -198,8 +192,8 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
198
192
|
if (!(await this.exists(path, cred))) {
|
|
199
193
|
throw ErrnoError.With('ENOENT', path, 'unlink');
|
|
200
194
|
}
|
|
201
|
-
if (await this.
|
|
202
|
-
await this.
|
|
195
|
+
if (await this.writable.exists(path, cred)) {
|
|
196
|
+
await this.writable.unlink(path, cred);
|
|
203
197
|
}
|
|
204
198
|
// if it still exists add to the delete log
|
|
205
199
|
if (await this.exists(path, cred)) {
|
|
@@ -212,8 +206,8 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
212
206
|
if (!this.existsSync(path, cred)) {
|
|
213
207
|
throw ErrnoError.With('ENOENT', path, 'unlink');
|
|
214
208
|
}
|
|
215
|
-
if (this.
|
|
216
|
-
this.
|
|
209
|
+
if (this.writable.existsSync(path, cred)) {
|
|
210
|
+
this.writable.unlinkSync(path, cred);
|
|
217
211
|
}
|
|
218
212
|
// if it still exists add to the delete log
|
|
219
213
|
if (this.existsSync(path, cred)) {
|
|
@@ -225,8 +219,8 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
225
219
|
if (!(await this.exists(path, cred))) {
|
|
226
220
|
throw ErrnoError.With('ENOENT', path, 'rmdir');
|
|
227
221
|
}
|
|
228
|
-
if (await this.
|
|
229
|
-
await this.
|
|
222
|
+
if (await this.writable.exists(path, cred)) {
|
|
223
|
+
await this.writable.rmdir(path, cred);
|
|
230
224
|
}
|
|
231
225
|
if (await this.exists(path, cred)) {
|
|
232
226
|
// Check if directory is empty.
|
|
@@ -243,8 +237,8 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
243
237
|
if (!this.existsSync(path, cred)) {
|
|
244
238
|
throw ErrnoError.With('ENOENT', path, 'rmdir');
|
|
245
239
|
}
|
|
246
|
-
if (this.
|
|
247
|
-
this.
|
|
240
|
+
if (this.writable.existsSync(path, cred)) {
|
|
241
|
+
this.writable.rmdirSync(path, cred);
|
|
248
242
|
}
|
|
249
243
|
if (this.existsSync(path, cred)) {
|
|
250
244
|
// Check if directory is empty.
|
|
@@ -263,7 +257,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
263
257
|
}
|
|
264
258
|
// The below will throw should any of the parent directories fail to exist on _writable.
|
|
265
259
|
await this.createParentDirectories(path, cred);
|
|
266
|
-
await this.
|
|
260
|
+
await this.writable.mkdir(path, mode, cred);
|
|
267
261
|
}
|
|
268
262
|
mkdirSync(path, mode, cred) {
|
|
269
263
|
this.checkInitialized();
|
|
@@ -272,7 +266,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
272
266
|
}
|
|
273
267
|
// The below will throw should any of the parent directories fail to exist on _writable.
|
|
274
268
|
this.createParentDirectoriesSync(path, cred);
|
|
275
|
-
this.
|
|
269
|
+
this.writable.mkdirSync(path, mode, cred);
|
|
276
270
|
}
|
|
277
271
|
async readdir(path, cred) {
|
|
278
272
|
this.checkInitialized();
|
|
@@ -283,13 +277,13 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
283
277
|
// Readdir in both, check delete log on RO file system's listing, merge, return.
|
|
284
278
|
const contents = [];
|
|
285
279
|
try {
|
|
286
|
-
contents.push(...(await this.
|
|
280
|
+
contents.push(...(await this.writable.readdir(path, cred)));
|
|
287
281
|
}
|
|
288
282
|
catch (e) {
|
|
289
283
|
// NOP.
|
|
290
284
|
}
|
|
291
285
|
try {
|
|
292
|
-
contents.push(...(await this.
|
|
286
|
+
contents.push(...(await this.readable.readdir(path, cred)).filter((fPath) => !this._deletedFiles.has(`${path}/${fPath}`)));
|
|
293
287
|
}
|
|
294
288
|
catch (e) {
|
|
295
289
|
// NOP.
|
|
@@ -310,13 +304,13 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
310
304
|
// Readdir in both, check delete log on RO file system's listing, merge, return.
|
|
311
305
|
let contents = [];
|
|
312
306
|
try {
|
|
313
|
-
contents = contents.concat(this.
|
|
307
|
+
contents = contents.concat(this.writable.readdirSync(path, cred));
|
|
314
308
|
}
|
|
315
309
|
catch (e) {
|
|
316
310
|
// NOP.
|
|
317
311
|
}
|
|
318
312
|
try {
|
|
319
|
-
contents = contents.concat(this.
|
|
313
|
+
contents = contents.concat(this.readable.readdirSync(path, cred).filter((fPath) => !this._deletedFiles.has(`${path}/${fPath}`)));
|
|
320
314
|
}
|
|
321
315
|
catch (e) {
|
|
322
316
|
// NOP.
|
|
@@ -339,7 +333,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
339
333
|
return;
|
|
340
334
|
}
|
|
341
335
|
this._deleteLogUpdatePending = true;
|
|
342
|
-
const log = await this.
|
|
336
|
+
const log = await this.writable.openFile(deletionLogPath, parseFlag('w'), cred);
|
|
343
337
|
try {
|
|
344
338
|
await log.write(encode(this._deleteLog));
|
|
345
339
|
if (this._deleteLogUpdateNeeded) {
|
|
@@ -386,25 +380,25 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
386
380
|
*/
|
|
387
381
|
createParentDirectoriesSync(path, cred) {
|
|
388
382
|
let parent = dirname(path), toCreate = [];
|
|
389
|
-
while (!this.
|
|
383
|
+
while (!this.writable.existsSync(parent, cred)) {
|
|
390
384
|
toCreate.push(parent);
|
|
391
385
|
parent = dirname(parent);
|
|
392
386
|
}
|
|
393
387
|
toCreate = toCreate.reverse();
|
|
394
388
|
for (const p of toCreate) {
|
|
395
|
-
this.
|
|
389
|
+
this.writable.mkdirSync(p, this.statSync(p, cred).mode, cred);
|
|
396
390
|
}
|
|
397
391
|
}
|
|
398
392
|
async createParentDirectories(path, cred) {
|
|
399
393
|
let parent = dirname(path), toCreate = [];
|
|
400
|
-
while (!(await this.
|
|
394
|
+
while (!(await this.writable.exists(parent, cred))) {
|
|
401
395
|
toCreate.push(parent);
|
|
402
396
|
parent = dirname(parent);
|
|
403
397
|
}
|
|
404
398
|
toCreate = toCreate.reverse();
|
|
405
399
|
for (const p of toCreate) {
|
|
406
400
|
const stats = await this.stat(p, cred);
|
|
407
|
-
await this.
|
|
401
|
+
await this.writable.mkdir(p, stats.mode, cred);
|
|
408
402
|
}
|
|
409
403
|
}
|
|
410
404
|
/**
|
|
@@ -416,7 +410,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
416
410
|
if (!this.existsSync(path, cred)) {
|
|
417
411
|
throw ErrnoError.With('ENOENT', path, 'operateOnWriteable');
|
|
418
412
|
}
|
|
419
|
-
if (!this.
|
|
413
|
+
if (!this.writable.existsSync(path, cred)) {
|
|
420
414
|
// File is on readable storage. Copy to writable storage before
|
|
421
415
|
// changing its mode.
|
|
422
416
|
this.copyToWritableSync(path, cred);
|
|
@@ -426,7 +420,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
426
420
|
if (!(await this.exists(path, cred))) {
|
|
427
421
|
throw ErrnoError.With('ENOENT', path, 'operateOnWritable');
|
|
428
422
|
}
|
|
429
|
-
if (!(await this.
|
|
423
|
+
if (!(await this.writable.exists(path, cred))) {
|
|
430
424
|
return this.copyToWritable(path, cred);
|
|
431
425
|
}
|
|
432
426
|
}
|
|
@@ -437,28 +431,28 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
437
431
|
copyToWritableSync(path, cred) {
|
|
438
432
|
const stats = this.statSync(path, cred);
|
|
439
433
|
if (stats.isDirectory()) {
|
|
440
|
-
this.
|
|
434
|
+
this.writable.mkdirSync(path, stats.mode, cred);
|
|
441
435
|
return;
|
|
442
436
|
}
|
|
443
437
|
const data = new Uint8Array(stats.size);
|
|
444
|
-
const readable = this.
|
|
438
|
+
const readable = this.readable.openFileSync(path, parseFlag('r'), cred);
|
|
445
439
|
readable.readSync(data);
|
|
446
440
|
readable.closeSync();
|
|
447
|
-
const writable = this.
|
|
441
|
+
const writable = this.writable.openFileSync(path, parseFlag('w'), cred);
|
|
448
442
|
writable.writeSync(data);
|
|
449
443
|
writable.closeSync();
|
|
450
444
|
}
|
|
451
445
|
async copyToWritable(path, cred) {
|
|
452
446
|
const stats = await this.stat(path, cred);
|
|
453
447
|
if (stats.isDirectory()) {
|
|
454
|
-
await this.
|
|
448
|
+
await this.writable.mkdir(path, stats.mode, cred);
|
|
455
449
|
return;
|
|
456
450
|
}
|
|
457
451
|
const data = new Uint8Array(stats.size);
|
|
458
|
-
const readable = await this.
|
|
452
|
+
const readable = await this.readable.openFile(path, parseFlag('r'), cred);
|
|
459
453
|
await readable.read(data);
|
|
460
454
|
await readable.close();
|
|
461
|
-
const writable = await this.
|
|
455
|
+
const writable = await this.writable.openFile(path, parseFlag('w'), cred);
|
|
462
456
|
await writable.write(data);
|
|
463
457
|
await writable.close();
|
|
464
458
|
}
|
|
@@ -469,27 +463,9 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
469
463
|
* file system.
|
|
470
464
|
* @internal
|
|
471
465
|
*/
|
|
472
|
-
export class OverlayFS extends
|
|
473
|
-
/**
|
|
474
|
-
* @param options The options to initialize the OverlayFS with
|
|
475
|
-
*/
|
|
476
|
-
constructor(options) {
|
|
477
|
-
super(new UnlockedOverlayFS(options));
|
|
478
|
-
}
|
|
479
|
-
getOverlayedFileSystems() {
|
|
480
|
-
return super.fs.getOverlayedFileSystems();
|
|
481
|
-
}
|
|
482
|
-
getDeletionLog() {
|
|
483
|
-
return super.fs.getDeletionLog();
|
|
484
|
-
}
|
|
485
|
-
resDeletionLog() {
|
|
486
|
-
return super.fs.getDeletionLog();
|
|
487
|
-
}
|
|
488
|
-
unwrap() {
|
|
489
|
-
return super.fs;
|
|
490
|
-
}
|
|
466
|
+
export class OverlayFS extends Mutexed(UnmutexedOverlayFS) {
|
|
491
467
|
}
|
|
492
|
-
|
|
468
|
+
const _Overlay = {
|
|
493
469
|
name: 'Overlay',
|
|
494
470
|
options: {
|
|
495
471
|
writable: {
|
|
@@ -510,3 +486,4 @@ export const Overlay = {
|
|
|
510
486
|
return new OverlayFS(options);
|
|
511
487
|
},
|
|
512
488
|
};
|
|
489
|
+
export const Overlay = _Overlay;
|
|
@@ -53,7 +53,7 @@ interface FSRequest<TMethod extends FSMethod = FSMethod> extends RPC.Request {
|
|
|
53
53
|
method: TMethod;
|
|
54
54
|
args: Parameters<FSMethods[TMethod]>;
|
|
55
55
|
}
|
|
56
|
-
declare const PortFS_base: import("../../
|
|
56
|
+
declare const PortFS_base: import("../../mixins/shared.js").Mixin<typeof FileSystem, {
|
|
57
57
|
_sync?: FileSystem | undefined;
|
|
58
58
|
queueDone(): Promise<void>;
|
|
59
59
|
ready(): Promise<void>;
|
|
@@ -111,7 +111,7 @@ export type FileOrFSRequest = FSRequest | FileRequest;
|
|
|
111
111
|
export declare function handleRequest(port: RPC.Port, fs: FileSystem, request: FileOrFSRequest): Promise<void>;
|
|
112
112
|
export declare function attachFS(port: RPC.Port, fs: FileSystem): void;
|
|
113
113
|
export declare function detachFS(port: RPC.Port, fs: FileSystem): void;
|
|
114
|
-
export declare const
|
|
114
|
+
export declare const _Port: {
|
|
115
115
|
name: string;
|
|
116
116
|
options: {
|
|
117
117
|
port: {
|
|
@@ -129,5 +129,9 @@ export declare const Port: {
|
|
|
129
129
|
isAvailable(): Promise<boolean>;
|
|
130
130
|
create(options: RPC.Options): PortFS;
|
|
131
131
|
};
|
|
132
|
+
type _port = typeof _Port;
|
|
133
|
+
interface Port extends _port {
|
|
134
|
+
}
|
|
135
|
+
export declare const Port: Port;
|
|
132
136
|
export declare function resolveRemoteMount<T extends Backend>(port: RPC.Port, config: MountConfiguration<T>, _depth?: number): Promise<FilesystemOf<T>>;
|
|
133
137
|
export {};
|
package/dist/backends/port/fs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Errno, ErrnoError } from '../../error.js';
|
|
2
2
|
import { File } from '../../file.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FileSystem } from '../../filesystem.js';
|
|
4
|
+
import { Async } from '../../mixins/async.js';
|
|
4
5
|
import { Stats } from '../../stats.js';
|
|
5
6
|
import { InMemory } from '../memory.js';
|
|
6
7
|
import * as RPC from './rpc.js';
|
|
@@ -210,7 +211,7 @@ export function attachFS(port, fs) {
|
|
|
210
211
|
export function detachFS(port, fs) {
|
|
211
212
|
RPC.detach(port, request => handleRequest(port, fs, request));
|
|
212
213
|
}
|
|
213
|
-
export const
|
|
214
|
+
export const _Port = {
|
|
214
215
|
name: 'Port',
|
|
215
216
|
options: {
|
|
216
217
|
port: {
|
|
@@ -237,6 +238,7 @@ export const Port = {
|
|
|
237
238
|
return new PortFS(options);
|
|
238
239
|
},
|
|
239
240
|
};
|
|
241
|
+
export const Port = _Port;
|
|
240
242
|
export async function resolveRemoteMount(port, config, _depth = 0) {
|
|
241
243
|
const stopAndReplay = RPC.catchMessages(port);
|
|
242
244
|
const fs = await resolveMountConfig(config, _depth);
|