@zenfs/core 2.5.7 → 2.5.8
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/store/fs.js +4 -8
- package/dist/internal/filesystem.d.ts +4 -4
- package/dist/internal/index_fs.js +6 -8
- package/dist/internal/inode.js +3 -0
- package/dist/node/promises.d.ts +1 -1
- package/dist/node/promises.js +2 -0
- package/package.json +4 -1
- package/tests/common/inode.test.ts +8 -0
|
@@ -454,12 +454,10 @@ export class StoreFS extends FileSystem {
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
async createFile(path, options) {
|
|
457
|
-
options.mode
|
|
458
|
-
return await this.commitNew(path, options, new Uint8Array());
|
|
457
|
+
return await this.commitNew(path, { ...options, mode: options.mode | S_IFREG }, new Uint8Array());
|
|
459
458
|
}
|
|
460
459
|
createFileSync(path, options) {
|
|
461
|
-
options.mode
|
|
462
|
-
return this.commitNewSync(path, options, new Uint8Array());
|
|
460
|
+
return this.commitNewSync(path, { ...options, mode: options.mode | S_IFREG }, new Uint8Array());
|
|
463
461
|
}
|
|
464
462
|
async unlink(path) {
|
|
465
463
|
return this.remove(path, false);
|
|
@@ -478,12 +476,10 @@ export class StoreFS extends FileSystem {
|
|
|
478
476
|
this.removeSync(path, true);
|
|
479
477
|
}
|
|
480
478
|
async mkdir(path, options) {
|
|
481
|
-
options.mode
|
|
482
|
-
return await this.commitNew(path, options, encodeUTF8('{}'));
|
|
479
|
+
return await this.commitNew(path, { ...options, mode: options.mode | S_IFDIR }, encodeUTF8('{}'));
|
|
483
480
|
}
|
|
484
481
|
mkdirSync(path, options) {
|
|
485
|
-
options.mode
|
|
486
|
-
return this.commitNewSync(path, options, encodeUTF8('{}'));
|
|
482
|
+
return this.commitNewSync(path, { ...options, mode: options.mode | S_IFDIR }, encodeUTF8('{}'));
|
|
487
483
|
}
|
|
488
484
|
async readdir(path) {
|
|
489
485
|
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
@@ -91,21 +91,21 @@ export interface FileSystemAttributes {
|
|
|
91
91
|
* @category Internals
|
|
92
92
|
* @internal
|
|
93
93
|
*/
|
|
94
|
-
export interface CreationOptions extends Partial<InodeLike
|
|
94
|
+
export interface CreationOptions extends Readonly<Partial<InodeLike>> {
|
|
95
95
|
/**
|
|
96
96
|
* The uid to create the file.
|
|
97
97
|
* This is ignored if the FS supports setuid and the setuid bit is set
|
|
98
98
|
*/
|
|
99
|
-
uid: number;
|
|
99
|
+
readonly uid: number;
|
|
100
100
|
/**
|
|
101
101
|
* The gid to create the file.
|
|
102
102
|
* This is ignored if the FS supports setgid and the setgid bit is set
|
|
103
103
|
*/
|
|
104
|
-
gid: number;
|
|
104
|
+
readonly gid: number;
|
|
105
105
|
/**
|
|
106
106
|
* The mode to create the file with.
|
|
107
107
|
*/
|
|
108
|
-
mode: number;
|
|
108
|
+
readonly mode: number;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Options for streaming operations
|
|
@@ -94,13 +94,13 @@ export class IndexFS extends FileSystem {
|
|
|
94
94
|
const inode = this.index.get(path);
|
|
95
95
|
if (!inode)
|
|
96
96
|
throw withErrno('ENOENT');
|
|
97
|
-
return inode;
|
|
97
|
+
return new Inode(inode);
|
|
98
98
|
}
|
|
99
99
|
statSync(path) {
|
|
100
100
|
const inode = this.index.get(path);
|
|
101
101
|
if (!inode)
|
|
102
102
|
throw withErrno('ENOENT');
|
|
103
|
-
return inode;
|
|
103
|
+
return new Inode(inode);
|
|
104
104
|
}
|
|
105
105
|
async touch(path, metadata) {
|
|
106
106
|
const inode = this.index.get(path) ?? _throw(withErrno('ENOENT'));
|
|
@@ -165,21 +165,19 @@ export class IndexFS extends FileSystem {
|
|
|
165
165
|
return inode;
|
|
166
166
|
}
|
|
167
167
|
async createFile(path, options) {
|
|
168
|
-
options.mode
|
|
169
|
-
return this.create(path, options);
|
|
168
|
+
return this.create(path, { ...options, mode: options.mode | S_IFREG });
|
|
170
169
|
}
|
|
171
170
|
createFileSync(path, options) {
|
|
172
|
-
options.mode
|
|
173
|
-
return this.create(path, options);
|
|
171
|
+
return this.create(path, { ...options, mode: options.mode | S_IFREG });
|
|
174
172
|
}
|
|
175
173
|
async mkdir(path, options) {
|
|
176
|
-
options.mode
|
|
174
|
+
options = { ...options, mode: options.mode | S_IFDIR };
|
|
177
175
|
const inode = this.create(path, options);
|
|
178
176
|
await this._mkdir?.(path, options);
|
|
179
177
|
return inode;
|
|
180
178
|
}
|
|
181
179
|
mkdirSync(path, options) {
|
|
182
|
-
options.mode
|
|
180
|
+
options = { ...options, mode: options.mode | S_IFDIR };
|
|
183
181
|
const inode = this.create(path, options);
|
|
184
182
|
this._mkdirSync?.(path, options);
|
|
185
183
|
return inode;
|
package/dist/internal/inode.js
CHANGED
|
@@ -451,6 +451,9 @@ let Inode = (() => {
|
|
|
451
451
|
data = args[0];
|
|
452
452
|
args = [sizeof(Inode)];
|
|
453
453
|
}
|
|
454
|
+
if (args[0] instanceof Inode) {
|
|
455
|
+
args = [new Uint8Array(args[0].buffer, args[0].byteOffset, args[0].byteLength)];
|
|
456
|
+
}
|
|
454
457
|
super(...args);
|
|
455
458
|
__runInitializers(this, ___data_extraInitializers);
|
|
456
459
|
if (this.byteLength < sizeof(Inode)) {
|
package/dist/node/promises.d.ts
CHANGED
|
@@ -239,7 +239,7 @@ export declare function writeFile(this: V_Context, path: fs.PathLike | promises.
|
|
|
239
239
|
* @option mode Defaults to `0644`.
|
|
240
240
|
* @option flag Defaults to `'a'`.
|
|
241
241
|
*/
|
|
242
|
-
export declare function appendFile(this: V_Context, path: fs.PathLike | promises.FileHandle, data: FileContents
|
|
242
|
+
export declare function appendFile(this: V_Context, path: fs.PathLike | promises.FileHandle, data: FileContents | Iterable<string | ArrayBufferView> | AsyncIterable<string | ArrayBufferView>, _options?: BufferEncoding | (fs.EncodingOption & {
|
|
243
243
|
mode?: fs.Mode;
|
|
244
244
|
flag?: fs.OpenMode;
|
|
245
245
|
}) | null): Promise<void>;
|
package/dist/node/promises.js
CHANGED
|
@@ -641,6 +641,8 @@ export async function appendFile(path, data, _options) {
|
|
|
641
641
|
const $ex = { syscall: 'write', path: path instanceof FileHandle ? path['vfs'].path : path.toString() };
|
|
642
642
|
if (!(flag & constants.O_APPEND))
|
|
643
643
|
throw UV('EBADF', $ex);
|
|
644
|
+
if (typeof data != 'string' && !ArrayBuffer.isView(data))
|
|
645
|
+
throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received ' + typeof data);
|
|
644
646
|
const encodedData = typeof data == 'string' ? Buffer.from(data, options.encoding) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
645
647
|
const handle = __addDisposableResource(env_4, typeof path == 'object' && 'fd' in path ? path : await open.call(this, path, options.flag, options.mode), true);
|
|
646
648
|
await handle.appendFile(encodedData, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -90,5 +90,8 @@
|
|
|
90
90
|
"typedoc": "^0.28.18",
|
|
91
91
|
"typescript": "^6.0.0",
|
|
92
92
|
"typescript-eslint": "^8.58.0"
|
|
93
|
+
},
|
|
94
|
+
"allowScripts": {
|
|
95
|
+
"esbuild": true
|
|
93
96
|
}
|
|
94
97
|
}
|
|
@@ -17,4 +17,12 @@ suite('Inode manipulation', () => {
|
|
|
17
17
|
const newInode = Object.assign(new Inode(), inode);
|
|
18
18
|
assert.equal(newInode.mode, inode.mode);
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
test('Copy to new Inode using the constructor does not alias', () => {
|
|
22
|
+
const newInode = new Inode(inode);
|
|
23
|
+
assert.equal(newInode.mode, inode.mode);
|
|
24
|
+
|
|
25
|
+
newInode.mode = 0o40700;
|
|
26
|
+
assert.equal(inode.mode, 0o40755);
|
|
27
|
+
});
|
|
20
28
|
});
|