@zenfs/core 1.7.0 → 1.7.2
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/error.d.ts +4 -0
- package/dist/error.js +2 -2
- package/dist/filesystem.d.ts +1 -1
- package/dist/mixins/async.js +1 -1
- package/dist/vfs/promises.js +2 -1
- package/dist/vfs/sync.js +2 -1
- package/package.json +1 -1
- package/tests/fs/dir.test.ts +4 -4
- package/tests/fs/errors.test.ts +2 -3
package/dist/error.d.ts
CHANGED
|
@@ -176,6 +176,10 @@ export declare class ErrnoError extends Error implements NodeJS.ErrnoException {
|
|
|
176
176
|
* The kind of error
|
|
177
177
|
*/
|
|
178
178
|
errno: Errno;
|
|
179
|
+
/**
|
|
180
|
+
* A descriptive error message
|
|
181
|
+
*/
|
|
182
|
+
message: string;
|
|
179
183
|
path?: string | undefined;
|
|
180
184
|
syscall: string;
|
|
181
185
|
static fromJSON(json: ErrnoErrorJSON): ErrnoError;
|
package/dist/error.js
CHANGED
|
@@ -258,16 +258,16 @@ export class ErrnoError extends Error {
|
|
|
258
258
|
message = errorMessages[errno], path, syscall = '') {
|
|
259
259
|
super(message);
|
|
260
260
|
this.errno = errno;
|
|
261
|
+
this.message = message;
|
|
261
262
|
this.path = path;
|
|
262
263
|
this.syscall = syscall;
|
|
263
264
|
this.code = Errno[errno];
|
|
264
|
-
this.message = this.code + ': ' + message + (this.path ? `, '${this.path}'` : '');
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* @returns A friendly error message.
|
|
268
268
|
*/
|
|
269
269
|
toString() {
|
|
270
|
-
return this.message;
|
|
270
|
+
return this.code + ': ' + this.message + (this.path ? `, '${this.path}'` : '');
|
|
271
271
|
}
|
|
272
272
|
toJSON() {
|
|
273
273
|
return {
|
package/dist/filesystem.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface FileSystemMetadata {
|
|
|
55
55
|
* These are used by the VFS for optimizations.
|
|
56
56
|
* - setid: The FS supports setuid and setgid when creating files and directories.
|
|
57
57
|
*/
|
|
58
|
-
features
|
|
58
|
+
features?: ('setid' | '')[];
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Options used when creating files and directories
|
package/dist/mixins/async.js
CHANGED
|
@@ -252,7 +252,7 @@ export function Async(FS) {
|
|
|
252
252
|
(_b = (_a = this._sync) === null || _a === void 0 ? void 0 : _a[`${key}Sync`]) === null || _b === void 0 ? void 0 : _b.call(_a, ...args);
|
|
253
253
|
}
|
|
254
254
|
catch (e) {
|
|
255
|
-
throw new ErrnoError(e.errno, 'Out of sync!
|
|
255
|
+
throw new ErrnoError(e.errno, e.message + ' (Out of sync!)', e.path, key);
|
|
256
256
|
}
|
|
257
257
|
return result;
|
|
258
258
|
};
|
package/dist/vfs/promises.js
CHANGED
|
@@ -467,7 +467,8 @@ unlink;
|
|
|
467
467
|
* Manually apply setuid/setgid.
|
|
468
468
|
*/
|
|
469
469
|
async function applySetId(file, uid, gid) {
|
|
470
|
-
|
|
470
|
+
var _a;
|
|
471
|
+
if ((_a = file.fs.metadata().features) === null || _a === void 0 ? void 0 : _a.includes('setid'))
|
|
471
472
|
return;
|
|
472
473
|
const parent = await file.fs.stat(dirname(file.path));
|
|
473
474
|
await file.chown(parent.mode & constants.S_ISUID ? parent.uid : uid, // manually apply setuid/setgid
|
package/dist/vfs/sync.js
CHANGED
|
@@ -169,7 +169,8 @@ unlinkSync;
|
|
|
169
169
|
* Manually apply setuid/setgid.
|
|
170
170
|
*/
|
|
171
171
|
function applySetId(file, uid, gid) {
|
|
172
|
-
|
|
172
|
+
var _a;
|
|
173
|
+
if ((_a = file.fs.metadata().features) === null || _a === void 0 ? void 0 : _a.includes('setid'))
|
|
173
174
|
return;
|
|
174
175
|
const parent = file.fs.statSync(dirname(file.path));
|
|
175
176
|
file.chownSync(parent.mode & constants.S_ISUID ? parent.uid : uid, // manually apply setuid/setgid
|
package/package.json
CHANGED
package/tests/fs/dir.test.ts
CHANGED
|
@@ -93,13 +93,13 @@ suite('Dir', () => {
|
|
|
93
93
|
test('close()', async () => {
|
|
94
94
|
const dir = fs.opendirSync(testDirPath);
|
|
95
95
|
await dir.close();
|
|
96
|
-
rejects(dir.read()
|
|
96
|
+
rejects(dir.read());
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('closeSync()', () => {
|
|
100
100
|
const dir = fs.opendirSync(testDirPath);
|
|
101
101
|
dir.closeSync();
|
|
102
|
-
assert.throws(() => dir.readSync()
|
|
102
|
+
assert.throws(() => dir.readSync());
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
test('asynchronous iteration', async () => {
|
|
@@ -119,13 +119,13 @@ suite('Dir', () => {
|
|
|
119
119
|
test('read after directory is closed', async () => {
|
|
120
120
|
const dir = fs.opendirSync(testDirPath);
|
|
121
121
|
await dir.close();
|
|
122
|
-
await assert.rejects(dir.read()
|
|
122
|
+
await assert.rejects(dir.read());
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
test('readSync after directory is closed', () => {
|
|
126
126
|
const dir = fs.opendirSync(testDirPath);
|
|
127
127
|
dir.closeSync();
|
|
128
|
-
assert.throws(() => dir.readSync()
|
|
128
|
+
assert.throws(() => dir.readSync());
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
test('close multiple times', async () => {
|
package/tests/fs/errors.test.ts
CHANGED
|
@@ -9,12 +9,11 @@ suite('Error messages', () => {
|
|
|
9
9
|
const path = '/non-existent';
|
|
10
10
|
|
|
11
11
|
fs.promises.stat(path).catch((error: ErrnoError) => {
|
|
12
|
-
assert.equal(error.toString(), error.message);
|
|
13
12
|
assert.equal(error.bufferSize(), 4 + JSON.stringify(error.toJSON()).length);
|
|
14
13
|
});
|
|
15
14
|
|
|
16
|
-
const missing = { path
|
|
17
|
-
const existing = { path: existingFile
|
|
15
|
+
const missing = { path };
|
|
16
|
+
const existing = { path: existingFile };
|
|
18
17
|
|
|
19
18
|
test('stat', () => assert.rejects(() => fs.promises.stat(path), missing));
|
|
20
19
|
test('mkdir', () => assert.rejects(() => fs.promises.mkdir(existingFile, 0o666), existing));
|