@zenfs/core 1.2.3 → 1.2.4
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/config.d.ts +2 -2
- package/dist/config.js +1 -1
- package/dist/emulation/config.d.ts +1 -1
- package/dist/emulation/config.js +1 -1
- package/dist/file.js +6 -6
- package/package.json +1 -1
- package/src/config.ts +3 -3
- package/src/emulation/config.ts +1 -1
- package/src/file.ts +6 -4
package/dist/config.d.ts
CHANGED
|
@@ -54,13 +54,13 @@ export interface Configuration<T extends ConfigMounts> extends SharedConfig {
|
|
|
54
54
|
*/
|
|
55
55
|
disableAccessChecks: boolean;
|
|
56
56
|
/**
|
|
57
|
-
* If true, disables `read` and `readSync` from
|
|
57
|
+
* If true, disables `read` and `readSync` from updating the atime.
|
|
58
58
|
*
|
|
59
59
|
* This can increase performance.
|
|
60
60
|
* @experimental
|
|
61
61
|
* @default false
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
disableUpdateOnRead: boolean;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Configures ZenFS with single mount point /
|
package/dist/config.js
CHANGED
|
@@ -70,7 +70,7 @@ export async function configure(configuration) {
|
|
|
70
70
|
Object.assign(credentials, { uid, gid, suid: uid, sgid: gid, euid: uid, egid: gid });
|
|
71
71
|
cache.setEnabled(configuration.cacheStats ?? false);
|
|
72
72
|
config.checkAccess = !configuration.disableAccessChecks;
|
|
73
|
-
config.
|
|
73
|
+
config.updateOnRead = !configuration.disableUpdateOnRead;
|
|
74
74
|
if (configuration.addDevices) {
|
|
75
75
|
const devfs = new DeviceFS();
|
|
76
76
|
devfs.createDevice('/null', nullDevice);
|
package/dist/emulation/config.js
CHANGED
package/dist/file.js
CHANGED
|
@@ -358,13 +358,15 @@ export class PreloadFile extends File {
|
|
|
358
358
|
if (!isReadable(this.flag)) {
|
|
359
359
|
throw new ErrnoError(Errno.EPERM, 'File not opened with a readable mode.');
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
if (config.updateOnRead) {
|
|
362
|
+
this.dirty = true;
|
|
363
|
+
this.stats.atimeMs = Date.now();
|
|
364
|
+
}
|
|
362
365
|
position ?? (position = this.position);
|
|
363
366
|
let end = position + length;
|
|
364
367
|
if (end > this.stats.size) {
|
|
365
368
|
end = position + Math.max(this.stats.size - position, 0);
|
|
366
369
|
}
|
|
367
|
-
this.stats.atimeMs = Date.now();
|
|
368
370
|
this._position = end;
|
|
369
371
|
const bytesRead = end - position;
|
|
370
372
|
if (bytesRead == 0) {
|
|
@@ -384,8 +386,7 @@ export class PreloadFile extends File {
|
|
|
384
386
|
*/
|
|
385
387
|
async read(buffer, offset, length, position) {
|
|
386
388
|
const bytesRead = this._read(buffer, offset, length, position);
|
|
387
|
-
|
|
388
|
-
await this.sync();
|
|
389
|
+
await this.sync();
|
|
389
390
|
return { bytesRead, buffer };
|
|
390
391
|
}
|
|
391
392
|
/**
|
|
@@ -399,8 +400,7 @@ export class PreloadFile extends File {
|
|
|
399
400
|
*/
|
|
400
401
|
readSync(buffer, offset, length, position) {
|
|
401
402
|
const bytesRead = this._read(buffer, offset, length, position);
|
|
402
|
-
|
|
403
|
-
this.syncSync();
|
|
403
|
+
this.syncSync();
|
|
404
404
|
return bytesRead;
|
|
405
405
|
}
|
|
406
406
|
async chmod(mode) {
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -119,13 +119,13 @@ export interface Configuration<T extends ConfigMounts> extends SharedConfig {
|
|
|
119
119
|
disableAccessChecks: boolean;
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* If true, disables `read` and `readSync` from
|
|
122
|
+
* If true, disables `read` and `readSync` from updating the atime.
|
|
123
123
|
*
|
|
124
124
|
* This can increase performance.
|
|
125
125
|
* @experimental
|
|
126
126
|
* @default false
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
disableUpdateOnRead: boolean;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -153,7 +153,7 @@ export async function configure<T extends ConfigMounts>(configuration: Partial<C
|
|
|
153
153
|
|
|
154
154
|
cache.setEnabled(configuration.cacheStats ?? false);
|
|
155
155
|
config.checkAccess = !configuration.disableAccessChecks;
|
|
156
|
-
config.
|
|
156
|
+
config.updateOnRead = !configuration.disableUpdateOnRead;
|
|
157
157
|
|
|
158
158
|
if (configuration.addDevices) {
|
|
159
159
|
const devfs = new DeviceFS();
|
package/src/emulation/config.ts
CHANGED
package/src/file.ts
CHANGED
|
@@ -515,13 +515,15 @@ export class PreloadFile<FS extends FileSystem> extends File {
|
|
|
515
515
|
if (!isReadable(this.flag)) {
|
|
516
516
|
throw new ErrnoError(Errno.EPERM, 'File not opened with a readable mode.');
|
|
517
517
|
}
|
|
518
|
-
|
|
518
|
+
if (config.updateOnRead) {
|
|
519
|
+
this.dirty = true;
|
|
520
|
+
this.stats.atimeMs = Date.now();
|
|
521
|
+
}
|
|
519
522
|
position ??= this.position;
|
|
520
523
|
let end = position + length;
|
|
521
524
|
if (end > this.stats.size) {
|
|
522
525
|
end = position + Math.max(this.stats.size - position, 0);
|
|
523
526
|
}
|
|
524
|
-
this.stats.atimeMs = Date.now();
|
|
525
527
|
this._position = end;
|
|
526
528
|
const bytesRead = end - position;
|
|
527
529
|
if (bytesRead == 0) {
|
|
@@ -542,7 +544,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
|
|
|
542
544
|
*/
|
|
543
545
|
public async read<TBuffer extends ArrayBufferView>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{ bytesRead: number; buffer: TBuffer }> {
|
|
544
546
|
const bytesRead = this._read(buffer, offset, length, position);
|
|
545
|
-
|
|
547
|
+
await this.sync();
|
|
546
548
|
return { bytesRead, buffer };
|
|
547
549
|
}
|
|
548
550
|
|
|
@@ -557,7 +559,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
|
|
|
557
559
|
*/
|
|
558
560
|
public readSync(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number {
|
|
559
561
|
const bytesRead = this._read(buffer, offset, length, position);
|
|
560
|
-
|
|
562
|
+
this.syncSync();
|
|
561
563
|
return bytesRead;
|
|
562
564
|
}
|
|
563
565
|
|