@zenfs/core 2.7.4 → 2.7.6
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.js +0 -2
- package/dist/backends/cow.d.ts +2 -2
- package/dist/backends/cow.js +6 -14
- package/dist/backends/passthrough.d.ts +0 -54
- package/dist/backends/passthrough.js +0 -54
- package/dist/backends/port.d.ts +2 -6
- package/dist/backends/port.js +3 -11
- package/dist/backends/store/fs.d.ts +0 -9
- package/dist/backends/store/fs.js +1 -21
- package/dist/backends/store/store.d.ts +1 -1
- package/dist/backends/store/store.js +1 -5
- package/dist/internal/contexts.d.ts +1 -2
- package/dist/internal/credentials.d.ts +0 -3
- package/dist/internal/file_index.js +0 -1
- package/dist/internal/filesystem.js +2 -2
- package/dist/internal/index_fs.d.ts +2 -2
- package/dist/internal/index_fs.js +2 -2
- package/dist/internal/inode.d.ts +33 -45
- package/dist/internal/inode.js +12 -2
- package/dist/internal/ioctl.d.ts +83 -25
- package/dist/internal/ioctl.js +50 -185
- package/dist/internal/rpc.d.ts +16 -7
- package/dist/internal/rpc.js +2 -11
- package/dist/mixins/mutexed.d.ts +6 -41
- package/dist/mixins/mutexed.js +36 -109
- package/dist/mixins/sync.js +0 -2
- package/dist/node/async.js +2 -12
- package/dist/node/index.d.ts +1 -1
- package/dist/node/promises.d.ts +1 -6
- package/dist/node/promises.js +1 -1
- package/dist/node/stats.d.ts +25 -99
- package/dist/node/stats.js +18 -55
- package/dist/node/streams.d.ts +1 -37
- package/dist/node/sync.d.ts +1 -6
- package/dist/node/sync.js +2 -2
- package/dist/polyfills.js +9 -0
- package/dist/utils.d.ts +0 -4
- package/dist/vfs/acl.d.ts +1 -3
- package/dist/vfs/acl.js +1 -3
- package/dist/vfs/async.js +0 -5
- package/dist/vfs/dir.d.ts +3 -0
- package/dist/vfs/dir.js +4 -1
- package/dist/vfs/file.d.ts +1 -8
- package/dist/vfs/file.js +1 -3
- package/dist/vfs/sync.js +0 -1
- package/dist/vfs/vcache.js +0 -1
- package/dist/vfs/xattr.d.ts +2 -0
- package/dist/vfs/xattr.js +5 -4
- package/package.json +2 -3
- package/tests/common/context.test.ts +1 -1
- package/tests/common/mutex.test.ts +0 -61
package/dist/mixins/mutexed.js
CHANGED
|
@@ -51,40 +51,15 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
53
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
54
|
-
import {
|
|
55
|
-
import { err } from 'kerium/log';
|
|
54
|
+
import { RwLockable } from 'kerium/locks';
|
|
56
55
|
import '../polyfills.js';
|
|
57
|
-
/**
|
|
58
|
-
* @category Internals
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
export class MutexLock {
|
|
62
|
-
previous;
|
|
63
|
-
current = Promise.withResolvers();
|
|
64
|
-
_isLocked = true;
|
|
65
|
-
get isLocked() {
|
|
66
|
-
return this._isLocked;
|
|
67
|
-
}
|
|
68
|
-
constructor(previous) {
|
|
69
|
-
this.previous = previous;
|
|
70
|
-
}
|
|
71
|
-
async done() {
|
|
72
|
-
await this.previous?.done();
|
|
73
|
-
await this.current.promise;
|
|
74
|
-
}
|
|
75
|
-
unlock() {
|
|
76
|
-
this.current.resolve();
|
|
77
|
-
this._isLocked = false;
|
|
78
|
-
}
|
|
79
|
-
[Symbol.dispose]() {
|
|
80
|
-
this.unlock();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
56
|
/**
|
|
84
57
|
* @hidden
|
|
85
58
|
* @category Internals
|
|
59
|
+
* @deprecated This is no longer needed and will be removed
|
|
60
|
+
* @todo [breaking] Remove
|
|
86
61
|
*/
|
|
87
|
-
export class _MutexedFS {
|
|
62
|
+
export class _MutexedFS extends RwLockable {
|
|
88
63
|
/**
|
|
89
64
|
* @internal
|
|
90
65
|
*/
|
|
@@ -122,59 +97,10 @@ export class _MutexedFS {
|
|
|
122
97
|
usage() {
|
|
123
98
|
return this._fs.usage();
|
|
124
99
|
}
|
|
125
|
-
/**
|
|
126
|
-
* The current locks
|
|
127
|
-
*/
|
|
128
|
-
currentLock;
|
|
129
|
-
/**
|
|
130
|
-
* Adds a lock for a path
|
|
131
|
-
*/
|
|
132
|
-
addLock() {
|
|
133
|
-
const lock = new MutexLock(this.currentLock);
|
|
134
|
-
this.currentLock = lock;
|
|
135
|
-
return lock;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Locks `path` asynchronously.
|
|
139
|
-
* If the path is currently locked, waits for it to be unlocked.
|
|
140
|
-
* @internal
|
|
141
|
-
*/
|
|
142
|
-
async lock(timeout = 5000) {
|
|
143
|
-
const previous = this.currentLock;
|
|
144
|
-
const lock = this.addLock();
|
|
145
|
-
const stack = new Error().stack;
|
|
146
|
-
setTimeout(() => {
|
|
147
|
-
if (lock.isLocked) {
|
|
148
|
-
const error = withErrno('EDEADLK');
|
|
149
|
-
error.stack += stack?.slice('Error'.length);
|
|
150
|
-
throw err(error);
|
|
151
|
-
}
|
|
152
|
-
}, timeout);
|
|
153
|
-
await previous?.done();
|
|
154
|
-
return lock;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Locks `path` asynchronously.
|
|
158
|
-
* If the path is currently locked, an error will be thrown
|
|
159
|
-
* @internal
|
|
160
|
-
*/
|
|
161
|
-
lockSync() {
|
|
162
|
-
if (this.currentLock?.isLocked) {
|
|
163
|
-
throw err(withErrno('EBUSY'));
|
|
164
|
-
}
|
|
165
|
-
return this.addLock();
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Whether `path` is locked
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
get isLocked() {
|
|
172
|
-
return !!this.currentLock?.isLocked;
|
|
173
|
-
}
|
|
174
100
|
async rename(oldPath, newPath) {
|
|
175
101
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
176
102
|
try {
|
|
177
|
-
const _ = __addDisposableResource(env_1, await this.lock(), false);
|
|
103
|
+
const _ = __addDisposableResource(env_1, await this.lock('rw'), false);
|
|
178
104
|
await this._fs.rename(oldPath, newPath);
|
|
179
105
|
}
|
|
180
106
|
catch (e_1) {
|
|
@@ -188,7 +114,7 @@ export class _MutexedFS {
|
|
|
188
114
|
renameSync(oldPath, newPath) {
|
|
189
115
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
190
116
|
try {
|
|
191
|
-
const _ = __addDisposableResource(env_2, this.lockSync(), false);
|
|
117
|
+
const _ = __addDisposableResource(env_2, this.lockSync('rw'), false);
|
|
192
118
|
return this._fs.renameSync(oldPath, newPath);
|
|
193
119
|
}
|
|
194
120
|
catch (e_2) {
|
|
@@ -202,7 +128,7 @@ export class _MutexedFS {
|
|
|
202
128
|
async stat(path) {
|
|
203
129
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
204
130
|
try {
|
|
205
|
-
const _ = __addDisposableResource(env_3, await this.lock(), false);
|
|
131
|
+
const _ = __addDisposableResource(env_3, await this.lock('ro'), false);
|
|
206
132
|
return await this._fs.stat(path);
|
|
207
133
|
}
|
|
208
134
|
catch (e_3) {
|
|
@@ -216,7 +142,7 @@ export class _MutexedFS {
|
|
|
216
142
|
statSync(path) {
|
|
217
143
|
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
218
144
|
try {
|
|
219
|
-
const _ = __addDisposableResource(env_4, this.lockSync(), false);
|
|
145
|
+
const _ = __addDisposableResource(env_4, this.lockSync('ro'), false);
|
|
220
146
|
return this._fs.statSync(path);
|
|
221
147
|
}
|
|
222
148
|
catch (e_4) {
|
|
@@ -230,7 +156,7 @@ export class _MutexedFS {
|
|
|
230
156
|
async touch(path, metadata) {
|
|
231
157
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
232
158
|
try {
|
|
233
|
-
const _ = __addDisposableResource(env_5, await this.lock(), false);
|
|
159
|
+
const _ = __addDisposableResource(env_5, await this.lock('rw'), false);
|
|
234
160
|
await this._fs.touch(path, metadata);
|
|
235
161
|
}
|
|
236
162
|
catch (e_5) {
|
|
@@ -244,7 +170,7 @@ export class _MutexedFS {
|
|
|
244
170
|
touchSync(path, metadata) {
|
|
245
171
|
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
246
172
|
try {
|
|
247
|
-
const _ = __addDisposableResource(env_6, this.lockSync(), false);
|
|
173
|
+
const _ = __addDisposableResource(env_6, this.lockSync('rw'), false);
|
|
248
174
|
this._fs.touchSync(path, metadata);
|
|
249
175
|
}
|
|
250
176
|
catch (e_6) {
|
|
@@ -258,7 +184,7 @@ export class _MutexedFS {
|
|
|
258
184
|
async createFile(path, options) {
|
|
259
185
|
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
260
186
|
try {
|
|
261
|
-
const _ = __addDisposableResource(env_7, await this.lock(), false);
|
|
187
|
+
const _ = __addDisposableResource(env_7, await this.lock('rw'), false);
|
|
262
188
|
return await this._fs.createFile(path, options);
|
|
263
189
|
}
|
|
264
190
|
catch (e_7) {
|
|
@@ -272,7 +198,7 @@ export class _MutexedFS {
|
|
|
272
198
|
createFileSync(path, options) {
|
|
273
199
|
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
274
200
|
try {
|
|
275
|
-
const _ = __addDisposableResource(env_8, this.lockSync(), false);
|
|
201
|
+
const _ = __addDisposableResource(env_8, this.lockSync('rw'), false);
|
|
276
202
|
return this._fs.createFileSync(path, options);
|
|
277
203
|
}
|
|
278
204
|
catch (e_8) {
|
|
@@ -286,7 +212,7 @@ export class _MutexedFS {
|
|
|
286
212
|
async unlink(path) {
|
|
287
213
|
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
288
214
|
try {
|
|
289
|
-
const _ = __addDisposableResource(env_9, await this.lock(), false);
|
|
215
|
+
const _ = __addDisposableResource(env_9, await this.lock('rw'), false);
|
|
290
216
|
await this._fs.unlink(path);
|
|
291
217
|
}
|
|
292
218
|
catch (e_9) {
|
|
@@ -300,7 +226,7 @@ export class _MutexedFS {
|
|
|
300
226
|
unlinkSync(path) {
|
|
301
227
|
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
302
228
|
try {
|
|
303
|
-
const _ = __addDisposableResource(env_10, this.lockSync(), false);
|
|
229
|
+
const _ = __addDisposableResource(env_10, this.lockSync('rw'), false);
|
|
304
230
|
return this._fs.unlinkSync(path);
|
|
305
231
|
}
|
|
306
232
|
catch (e_10) {
|
|
@@ -314,7 +240,7 @@ export class _MutexedFS {
|
|
|
314
240
|
async rmdir(path) {
|
|
315
241
|
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
316
242
|
try {
|
|
317
|
-
const _ = __addDisposableResource(env_11, await this.lock(), false);
|
|
243
|
+
const _ = __addDisposableResource(env_11, await this.lock('rw'), false);
|
|
318
244
|
await this._fs.rmdir(path);
|
|
319
245
|
}
|
|
320
246
|
catch (e_11) {
|
|
@@ -328,7 +254,7 @@ export class _MutexedFS {
|
|
|
328
254
|
rmdirSync(path) {
|
|
329
255
|
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
330
256
|
try {
|
|
331
|
-
const _ = __addDisposableResource(env_12, this.lockSync(), false);
|
|
257
|
+
const _ = __addDisposableResource(env_12, this.lockSync('rw'), false);
|
|
332
258
|
return this._fs.rmdirSync(path);
|
|
333
259
|
}
|
|
334
260
|
catch (e_12) {
|
|
@@ -342,7 +268,7 @@ export class _MutexedFS {
|
|
|
342
268
|
async mkdir(path, options) {
|
|
343
269
|
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
344
270
|
try {
|
|
345
|
-
const _ = __addDisposableResource(env_13, await this.lock(), false);
|
|
271
|
+
const _ = __addDisposableResource(env_13, await this.lock('rw'), false);
|
|
346
272
|
return await this._fs.mkdir(path, options);
|
|
347
273
|
}
|
|
348
274
|
catch (e_13) {
|
|
@@ -356,7 +282,7 @@ export class _MutexedFS {
|
|
|
356
282
|
mkdirSync(path, options) {
|
|
357
283
|
const env_14 = { stack: [], error: void 0, hasError: false };
|
|
358
284
|
try {
|
|
359
|
-
const _ = __addDisposableResource(env_14, this.lockSync(), false);
|
|
285
|
+
const _ = __addDisposableResource(env_14, this.lockSync('rw'), false);
|
|
360
286
|
return this._fs.mkdirSync(path, options);
|
|
361
287
|
}
|
|
362
288
|
catch (e_14) {
|
|
@@ -370,7 +296,7 @@ export class _MutexedFS {
|
|
|
370
296
|
async readdir(path) {
|
|
371
297
|
const env_15 = { stack: [], error: void 0, hasError: false };
|
|
372
298
|
try {
|
|
373
|
-
const _ = __addDisposableResource(env_15, await this.lock(), false);
|
|
299
|
+
const _ = __addDisposableResource(env_15, await this.lock('ro'), false);
|
|
374
300
|
return await this._fs.readdir(path);
|
|
375
301
|
}
|
|
376
302
|
catch (e_15) {
|
|
@@ -384,7 +310,7 @@ export class _MutexedFS {
|
|
|
384
310
|
readdirSync(path) {
|
|
385
311
|
const env_16 = { stack: [], error: void 0, hasError: false };
|
|
386
312
|
try {
|
|
387
|
-
const _ = __addDisposableResource(env_16, this.lockSync(), false);
|
|
313
|
+
const _ = __addDisposableResource(env_16, this.lockSync('ro'), false);
|
|
388
314
|
return this._fs.readdirSync(path);
|
|
389
315
|
}
|
|
390
316
|
catch (e_16) {
|
|
@@ -398,7 +324,7 @@ export class _MutexedFS {
|
|
|
398
324
|
async exists(path) {
|
|
399
325
|
const env_17 = { stack: [], error: void 0, hasError: false };
|
|
400
326
|
try {
|
|
401
|
-
const _ = __addDisposableResource(env_17, await this.lock(), false);
|
|
327
|
+
const _ = __addDisposableResource(env_17, await this.lock('ro'), false);
|
|
402
328
|
return await this._fs.exists(path);
|
|
403
329
|
}
|
|
404
330
|
catch (e_17) {
|
|
@@ -412,7 +338,7 @@ export class _MutexedFS {
|
|
|
412
338
|
existsSync(path) {
|
|
413
339
|
const env_18 = { stack: [], error: void 0, hasError: false };
|
|
414
340
|
try {
|
|
415
|
-
const _ = __addDisposableResource(env_18, this.lockSync(), false);
|
|
341
|
+
const _ = __addDisposableResource(env_18, this.lockSync('ro'), false);
|
|
416
342
|
return this._fs.existsSync(path);
|
|
417
343
|
}
|
|
418
344
|
catch (e_18) {
|
|
@@ -426,7 +352,7 @@ export class _MutexedFS {
|
|
|
426
352
|
async link(srcpath, dstpath) {
|
|
427
353
|
const env_19 = { stack: [], error: void 0, hasError: false };
|
|
428
354
|
try {
|
|
429
|
-
const _ = __addDisposableResource(env_19, await this.lock(), false);
|
|
355
|
+
const _ = __addDisposableResource(env_19, await this.lock('rw'), false);
|
|
430
356
|
await this._fs.link(srcpath, dstpath);
|
|
431
357
|
}
|
|
432
358
|
catch (e_19) {
|
|
@@ -440,7 +366,7 @@ export class _MutexedFS {
|
|
|
440
366
|
linkSync(srcpath, dstpath) {
|
|
441
367
|
const env_20 = { stack: [], error: void 0, hasError: false };
|
|
442
368
|
try {
|
|
443
|
-
const _ = __addDisposableResource(env_20, this.lockSync(), false);
|
|
369
|
+
const _ = __addDisposableResource(env_20, this.lockSync('rw'), false);
|
|
444
370
|
return this._fs.linkSync(srcpath, dstpath);
|
|
445
371
|
}
|
|
446
372
|
catch (e_20) {
|
|
@@ -454,7 +380,7 @@ export class _MutexedFS {
|
|
|
454
380
|
async sync() {
|
|
455
381
|
const env_21 = { stack: [], error: void 0, hasError: false };
|
|
456
382
|
try {
|
|
457
|
-
const _ = __addDisposableResource(env_21, await this.lock(), false);
|
|
383
|
+
const _ = __addDisposableResource(env_21, await this.lock('rw'), false);
|
|
458
384
|
await this._fs.sync();
|
|
459
385
|
}
|
|
460
386
|
catch (e_21) {
|
|
@@ -468,7 +394,7 @@ export class _MutexedFS {
|
|
|
468
394
|
syncSync() {
|
|
469
395
|
const env_22 = { stack: [], error: void 0, hasError: false };
|
|
470
396
|
try {
|
|
471
|
-
const _ = __addDisposableResource(env_22, this.lockSync(), false);
|
|
397
|
+
const _ = __addDisposableResource(env_22, this.lockSync('rw'), false);
|
|
472
398
|
return this._fs.syncSync();
|
|
473
399
|
}
|
|
474
400
|
catch (e_22) {
|
|
@@ -482,7 +408,7 @@ export class _MutexedFS {
|
|
|
482
408
|
async read(path, buffer, offset, end) {
|
|
483
409
|
const env_23 = { stack: [], error: void 0, hasError: false };
|
|
484
410
|
try {
|
|
485
|
-
const _ = __addDisposableResource(env_23, await this.lock(), false);
|
|
411
|
+
const _ = __addDisposableResource(env_23, await this.lock('ro'), false);
|
|
486
412
|
return await this._fs.read(path, buffer, offset, end);
|
|
487
413
|
}
|
|
488
414
|
catch (e_23) {
|
|
@@ -496,7 +422,7 @@ export class _MutexedFS {
|
|
|
496
422
|
readSync(path, buffer, offset, end) {
|
|
497
423
|
const env_24 = { stack: [], error: void 0, hasError: false };
|
|
498
424
|
try {
|
|
499
|
-
const _ = __addDisposableResource(env_24, this.lockSync(), false);
|
|
425
|
+
const _ = __addDisposableResource(env_24, this.lockSync('ro'), false);
|
|
500
426
|
return this._fs.readSync(path, buffer, offset, end);
|
|
501
427
|
}
|
|
502
428
|
catch (e_24) {
|
|
@@ -510,7 +436,7 @@ export class _MutexedFS {
|
|
|
510
436
|
async write(path, buffer, offset) {
|
|
511
437
|
const env_25 = { stack: [], error: void 0, hasError: false };
|
|
512
438
|
try {
|
|
513
|
-
const _ = __addDisposableResource(env_25, await this.lock(), false);
|
|
439
|
+
const _ = __addDisposableResource(env_25, await this.lock('rw'), false);
|
|
514
440
|
return await this._fs.write(path, buffer, offset);
|
|
515
441
|
}
|
|
516
442
|
catch (e_25) {
|
|
@@ -524,7 +450,7 @@ export class _MutexedFS {
|
|
|
524
450
|
writeSync(path, buffer, offset) {
|
|
525
451
|
const env_26 = { stack: [], error: void 0, hasError: false };
|
|
526
452
|
try {
|
|
527
|
-
const _ = __addDisposableResource(env_26, this.lockSync(), false);
|
|
453
|
+
const _ = __addDisposableResource(env_26, this.lockSync('rw'), false);
|
|
528
454
|
return this._fs.writeSync(path, buffer, offset);
|
|
529
455
|
}
|
|
530
456
|
catch (e_26) {
|
|
@@ -538,7 +464,7 @@ export class _MutexedFS {
|
|
|
538
464
|
streamRead(path, options) {
|
|
539
465
|
const env_27 = { stack: [], error: void 0, hasError: false };
|
|
540
466
|
try {
|
|
541
|
-
const _ = __addDisposableResource(env_27, this.lockSync(), false);
|
|
467
|
+
const _ = __addDisposableResource(env_27, this.lockSync('ro'), false);
|
|
542
468
|
return this._fs.streamRead(path, options);
|
|
543
469
|
}
|
|
544
470
|
catch (e_27) {
|
|
@@ -552,7 +478,7 @@ export class _MutexedFS {
|
|
|
552
478
|
streamWrite(path, options) {
|
|
553
479
|
const env_28 = { stack: [], error: void 0, hasError: false };
|
|
554
480
|
try {
|
|
555
|
-
const _ = __addDisposableResource(env_28, this.lockSync(), false);
|
|
481
|
+
const _ = __addDisposableResource(env_28, this.lockSync('rw'), false);
|
|
556
482
|
return this._fs.streamWrite(path, options);
|
|
557
483
|
}
|
|
558
484
|
catch (e_28) {
|
|
@@ -566,7 +492,7 @@ export class _MutexedFS {
|
|
|
566
492
|
async ioctl(context, command, ...args) {
|
|
567
493
|
const env_29 = { stack: [], error: void 0, hasError: false };
|
|
568
494
|
try {
|
|
569
|
-
const _ = __addDisposableResource(env_29, await this.lock(), false);
|
|
495
|
+
const _ = __addDisposableResource(env_29, await this.lock('rw'), false);
|
|
570
496
|
return await this._fs.ioctl({ ...context, fs: this._fs }, command, ...args);
|
|
571
497
|
}
|
|
572
498
|
catch (e_29) {
|
|
@@ -580,7 +506,7 @@ export class _MutexedFS {
|
|
|
580
506
|
ioctlSync(context, command, ...args) {
|
|
581
507
|
const env_30 = { stack: [], error: void 0, hasError: false };
|
|
582
508
|
try {
|
|
583
|
-
const _ = __addDisposableResource(env_30, this.lockSync(), false);
|
|
509
|
+
const _ = __addDisposableResource(env_30, this.lockSync('rw'), false);
|
|
584
510
|
return this._fs.ioctlSync({ ...context, fs: this._fs }, command, ...args);
|
|
585
511
|
}
|
|
586
512
|
catch (e_30) {
|
|
@@ -608,9 +534,10 @@ export class _MutexedFS {
|
|
|
608
534
|
* Instead of extending `FileSystem`,
|
|
609
535
|
* `MutexedFS` implements it in order to make sure all of the methods are passed through
|
|
610
536
|
*
|
|
611
|
-
* @todo Change `using _` to `using void` pending https://github.com/tc39/proposal-discard-binding
|
|
612
537
|
* @category Internals
|
|
613
538
|
* @internal
|
|
539
|
+
* @deprecated This is no longer needed and will be removed
|
|
540
|
+
* @todo [breaking] Remove
|
|
614
541
|
*/
|
|
615
542
|
export function Mutexed(FS) {
|
|
616
543
|
class MutexedFS extends _MutexedFS {
|
package/dist/mixins/sync.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Implements the asynchronous API in terms of the synchronous API.
|
|
3
3
|
* @category Internals
|
|
4
4
|
*/
|
|
5
|
-
/* eslint-disable @typescript-eslint/require-await */
|
|
6
5
|
export function Sync(FS) {
|
|
7
6
|
class SyncFS extends FS {
|
|
8
7
|
async exists(path) {
|
|
@@ -50,4 +49,3 @@ export function Sync(FS) {
|
|
|
50
49
|
}
|
|
51
50
|
return SyncFS;
|
|
52
51
|
}
|
|
53
|
-
/* eslint-enable @typescript-eslint/require-await */
|
package/dist/node/async.js
CHANGED
|
@@ -7,16 +7,6 @@ import * as promises from './promises.js';
|
|
|
7
7
|
import { BigIntStats } from './stats.js';
|
|
8
8
|
import { ReadStream, WriteStream } from './streams.js';
|
|
9
9
|
const nop = () => { };
|
|
10
|
-
/**
|
|
11
|
-
* Helper to collect an async iterator into an array
|
|
12
|
-
*/
|
|
13
|
-
async function collectAsyncIterator(it) {
|
|
14
|
-
const results = [];
|
|
15
|
-
for await (const result of it) {
|
|
16
|
-
results.push(result);
|
|
17
|
-
}
|
|
18
|
-
return results;
|
|
19
|
-
}
|
|
20
10
|
/**
|
|
21
11
|
* Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
|
|
22
12
|
*/
|
|
@@ -400,7 +390,7 @@ watch;
|
|
|
400
390
|
export function createReadStream(path, options) {
|
|
401
391
|
options = typeof options == 'object' ? options : { encoding: options };
|
|
402
392
|
const _handle = promises.open.call(this, path, 'r', options?.mode);
|
|
403
|
-
return new ReadStream({ ...options, autoClose: true }, _handle);
|
|
393
|
+
return new ReadStream({ ...options, autoClose: true, signal: options?.signal ?? undefined }, _handle);
|
|
404
394
|
}
|
|
405
395
|
createReadStream;
|
|
406
396
|
/**
|
|
@@ -490,7 +480,7 @@ openAsBlob;
|
|
|
490
480
|
export function glob(pattern, options, callback = nop) {
|
|
491
481
|
callback = typeof options == 'function' ? options : callback;
|
|
492
482
|
const it = promises.glob.call(this, pattern, typeof options === 'function' ? undefined : options);
|
|
493
|
-
|
|
483
|
+
Array.fromAsync(it)
|
|
494
484
|
.then(results => callback(null, results ?? []))
|
|
495
485
|
.catch((e) => callback(e));
|
|
496
486
|
}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './async.js';
|
|
|
3
3
|
export * from './dir.js';
|
|
4
4
|
export * as promises from './promises.js';
|
|
5
5
|
export { BigIntStatsFs, Stats, StatsFs } from './stats.js';
|
|
6
|
-
export type { StatsLike } from '
|
|
6
|
+
export type { StatsLike } from '../internal/inode.js';
|
|
7
7
|
export * from './streams.js';
|
|
8
8
|
export * from './sync.js';
|
|
9
9
|
export { Utf8Stream } from './utf8stream.js';
|
package/dist/node/promises.d.ts
CHANGED
|
@@ -356,13 +356,8 @@ export declare function mkdtemp(this: V_Context, prefix: string, options?: fs.Bu
|
|
|
356
356
|
* When the object is disposed, the directory and its contents will be removed asynchronously if it still exists.
|
|
357
357
|
* If the directory cannot be deleted, disposal will throw an error.
|
|
358
358
|
* The object has an async `remove()` method which will perform the same task.
|
|
359
|
-
* @todo Add `satisfies` and maybe change return type once @types/node adds this.
|
|
360
359
|
*/
|
|
361
|
-
export declare function mkdtempDisposable(this: V_Context, prefix: fs.PathLike, options?: fs.EncodingOption | fs.BufferEncodingOption): Promise<
|
|
362
|
-
path: string;
|
|
363
|
-
remove(): Promise<void>;
|
|
364
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
365
|
-
}>;
|
|
360
|
+
export declare function mkdtempDisposable(this: V_Context, prefix: fs.PathLike, options?: fs.EncodingOption | fs.BufferEncodingOption): Promise<promises.DisposableTempDir>;
|
|
366
361
|
/**
|
|
367
362
|
* Asynchronous `copyFile`. Copies a file.
|
|
368
363
|
* @param src The source file.
|
package/dist/node/promises.js
CHANGED
|
@@ -1018,7 +1018,6 @@ mkdtemp;
|
|
|
1018
1018
|
* When the object is disposed, the directory and its contents will be removed asynchronously if it still exists.
|
|
1019
1019
|
* If the directory cannot be deleted, disposal will throw an error.
|
|
1020
1020
|
* The object has an async `remove()` method which will perform the same task.
|
|
1021
|
-
* @todo Add `satisfies` and maybe change return type once @types/node adds this.
|
|
1022
1021
|
*/
|
|
1023
1022
|
export async function mkdtempDisposable(prefix, options) {
|
|
1024
1023
|
const path = _tempDirName(prefix);
|
|
@@ -1026,6 +1025,7 @@ export async function mkdtempDisposable(prefix, options) {
|
|
|
1026
1025
|
const remove = () => rm(path, { recursive: true, force: true });
|
|
1027
1026
|
return { path, remove, [Symbol.asyncDispose]: remove };
|
|
1028
1027
|
}
|
|
1028
|
+
mkdtempDisposable;
|
|
1029
1029
|
/**
|
|
1030
1030
|
* Asynchronous `copyFile`. Copies a file.
|
|
1031
1031
|
* @param src The source file.
|
package/dist/node/stats.d.ts
CHANGED
|
@@ -1,143 +1,71 @@
|
|
|
1
1
|
import type * as Node from 'node:fs';
|
|
2
2
|
import type { V_Context } from '../context.js';
|
|
3
|
-
import type { InodeFields } from '../internal/inode.js';
|
|
4
|
-
export interface
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
size: T;
|
|
10
|
-
/**
|
|
11
|
-
* Unix-style file mode (e.g. 0o644) that includes the item type
|
|
12
|
-
*/
|
|
13
|
-
mode: T;
|
|
14
|
-
/**
|
|
15
|
-
* Time of last access, since epoch
|
|
16
|
-
*/
|
|
17
|
-
atimeMs: T;
|
|
18
|
-
/**
|
|
19
|
-
* Time of last modification, since epoch
|
|
20
|
-
*/
|
|
21
|
-
mtimeMs: T;
|
|
22
|
-
/**
|
|
23
|
-
* Time of last time file status was changed, since epoch
|
|
24
|
-
*/
|
|
25
|
-
ctimeMs: T;
|
|
26
|
-
/**
|
|
27
|
-
* Time of file creation, since epoch
|
|
28
|
-
*/
|
|
29
|
-
birthtimeMs: T;
|
|
30
|
-
/**
|
|
31
|
-
* The id of the user that owns the file
|
|
32
|
-
*/
|
|
33
|
-
uid: T;
|
|
34
|
-
/**
|
|
35
|
-
* The id of the group that owns the file
|
|
36
|
-
*/
|
|
37
|
-
gid: T;
|
|
38
|
-
/**
|
|
39
|
-
* Inode number
|
|
40
|
-
*/
|
|
41
|
-
ino: T;
|
|
42
|
-
/**
|
|
43
|
-
* Number of hard links
|
|
44
|
-
*/
|
|
45
|
-
nlink: T;
|
|
3
|
+
import type { InodeFields, InodeLike, StatsLike } from '../internal/inode.js';
|
|
4
|
+
export interface StatsExtra<T extends number | bigint> {
|
|
5
|
+
/** ID of device containing file */
|
|
6
|
+
dev: T;
|
|
7
|
+
/** Block size for file system I/O */
|
|
8
|
+
blksize: T;
|
|
46
9
|
}
|
|
47
10
|
/**
|
|
48
11
|
* Provides information about a particular entry in the file system.
|
|
49
12
|
* Common code used by both Stats and BigIntStats.
|
|
50
13
|
*/
|
|
51
|
-
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T>, StatsLike {
|
|
14
|
+
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T>, StatsLike<T>, StatsExtra<T> {
|
|
52
15
|
protected abstract _isBigint: T extends bigint ? true : false;
|
|
53
16
|
protected _convert(arg: number | bigint | string | boolean): T;
|
|
54
17
|
get blocks(): T;
|
|
55
18
|
set blocks(value: T);
|
|
56
|
-
/**
|
|
57
|
-
* Unix-style file mode (e.g. 0o644) that includes the type of the item.
|
|
58
|
-
*/
|
|
19
|
+
/** Unix-style file mode (e.g. 0o644) that includes the type of the item. */
|
|
59
20
|
mode: T;
|
|
60
|
-
/**
|
|
61
|
-
* ID of device containing file
|
|
62
|
-
*/
|
|
21
|
+
/** ID of device containing file */
|
|
63
22
|
dev: T;
|
|
64
|
-
/**
|
|
65
|
-
* Inode number
|
|
66
|
-
*/
|
|
23
|
+
/** Inode number */
|
|
67
24
|
ino: T;
|
|
68
|
-
/**
|
|
69
|
-
* Device ID (if special file)
|
|
70
|
-
*/
|
|
25
|
+
/** Device ID (if special file) */
|
|
71
26
|
rdev: T;
|
|
72
|
-
/**
|
|
73
|
-
* Number of hard links
|
|
74
|
-
*/
|
|
27
|
+
/** Number of hard links */
|
|
75
28
|
nlink: T;
|
|
76
|
-
/**
|
|
77
|
-
* Block size for file system I/O
|
|
78
|
-
*/
|
|
29
|
+
/** Block size for file system I/O */
|
|
79
30
|
blksize: T;
|
|
80
|
-
/**
|
|
81
|
-
* User ID of owner
|
|
82
|
-
*/
|
|
31
|
+
/** User ID of owner */
|
|
83
32
|
uid: T;
|
|
84
|
-
/**
|
|
85
|
-
* Group ID of owner
|
|
86
|
-
*/
|
|
33
|
+
/** Group ID of owner */
|
|
87
34
|
gid: T;
|
|
88
|
-
/**
|
|
89
|
-
* Time of last access, since epoch
|
|
90
|
-
*/
|
|
35
|
+
/** Time of last access, since epoch */
|
|
91
36
|
atimeMs: T;
|
|
92
37
|
get atime(): Date;
|
|
93
38
|
set atime(value: Date);
|
|
94
39
|
get atimeInstant(): Temporal.Instant;
|
|
95
40
|
set atimeInstant(value: Temporal.Instant);
|
|
96
|
-
/**
|
|
97
|
-
* Time of last modification, since epoch
|
|
98
|
-
*/
|
|
41
|
+
/** Time of last modification, since epoch */
|
|
99
42
|
mtimeMs: T;
|
|
100
43
|
get mtime(): Date;
|
|
101
44
|
set mtime(value: Date);
|
|
102
45
|
get mtimeInstant(): Temporal.Instant;
|
|
103
46
|
set mtimeInstant(value: Temporal.Instant);
|
|
104
|
-
/**
|
|
105
|
-
* Time of last time file status was changed, since epoch
|
|
106
|
-
*/
|
|
47
|
+
/** Time of last time file status was changed, since epoch */
|
|
107
48
|
ctimeMs: T;
|
|
108
49
|
get ctime(): Date;
|
|
109
50
|
set ctime(value: Date);
|
|
110
51
|
get ctimeInstant(): Temporal.Instant;
|
|
111
52
|
set ctimeInstant(value: Temporal.Instant);
|
|
112
|
-
/**
|
|
113
|
-
* Time of file creation, since epoch
|
|
114
|
-
*/
|
|
53
|
+
/** Time of file creation, since epoch */
|
|
115
54
|
birthtimeMs: T;
|
|
116
55
|
get birthtime(): Date;
|
|
117
56
|
set birthtime(value: Date);
|
|
118
57
|
get birthtimeInstant(): Temporal.Instant;
|
|
119
58
|
set birthtimeInstant(value: Temporal.Instant);
|
|
120
|
-
/**
|
|
121
|
-
* Size of the item in bytes.
|
|
122
|
-
* For directories/symlinks, this is normally the size of the struct that represents the item.
|
|
123
|
-
*/
|
|
59
|
+
/** Size of the item in bytes. For directories/symlinks, this may be the size of the struct that represents the item. */
|
|
124
60
|
size: T;
|
|
125
|
-
/**
|
|
126
|
-
* @internal Used by inodes
|
|
127
|
-
*/
|
|
61
|
+
/** @internal Used by inodes */
|
|
128
62
|
data?: number;
|
|
129
|
-
/**
|
|
130
|
-
* @internal Used by inodes
|
|
131
|
-
*/
|
|
63
|
+
/** @internal Used by inodes */
|
|
132
64
|
flags?: number;
|
|
133
|
-
/**
|
|
134
|
-
* @internal Used by inodes
|
|
135
|
-
*/
|
|
65
|
+
/** @internal Used by inodes */
|
|
136
66
|
version?: number;
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, ...rest }?: Partial<StatsLike & InodeFields>);
|
|
67
|
+
/** Creates a new stats instance from a stats-like object. Can be used to copy stats (note) */
|
|
68
|
+
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, ...rest }?: Partial<InodeLike<number | bigint>>);
|
|
141
69
|
isFile(): boolean;
|
|
142
70
|
isDirectory(): boolean;
|
|
143
71
|
isSymbolicLink(): boolean;
|
|
@@ -183,8 +111,6 @@ export declare class BigIntStats extends StatsCommon<bigint> implements Node.Big
|
|
|
183
111
|
* @internal
|
|
184
112
|
*/
|
|
185
113
|
export declare function isStatsEqual<T extends number | bigint>(left: StatsCommon<T>, right: StatsCommon<T>): boolean;
|
|
186
|
-
/** @internal */
|
|
187
|
-
export declare const ZenFsType = 525687744115;
|
|
188
114
|
/**
|
|
189
115
|
* @hidden
|
|
190
116
|
*/
|