@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 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 immediately syncing the updated atime to the file system.
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
- disableSyncOnRead: boolean;
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.syncOnRead = !configuration.disableSyncOnRead;
73
+ config.updateOnRead = !configuration.disableUpdateOnRead;
74
74
  if (configuration.addDevices) {
75
75
  const devfs = new DeviceFS();
76
76
  devfs.createDevice('/null', nullDevice);
@@ -6,5 +6,5 @@ export declare const config: {
6
6
  /**
7
7
  * Whether to sync atime updates immediately when reading from a file
8
8
  */
9
- syncOnRead: boolean;
9
+ updateOnRead: boolean;
10
10
  };
@@ -6,5 +6,5 @@ export const config = {
6
6
  /**
7
7
  * Whether to sync atime updates immediately when reading from a file
8
8
  */
9
- syncOnRead: true,
9
+ updateOnRead: true,
10
10
  };
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
- this.dirty = true;
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
- if (config.syncOnRead)
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
- if (config.syncOnRead)
403
- this.syncSync();
403
+ this.syncSync();
404
404
  return bytesRead;
405
405
  }
406
406
  async chmod(mode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
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 immediately syncing the updated atime to the file system.
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
- disableSyncOnRead: boolean;
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.syncOnRead = !configuration.disableSyncOnRead;
156
+ config.updateOnRead = !configuration.disableUpdateOnRead;
157
157
 
158
158
  if (configuration.addDevices) {
159
159
  const devfs = new DeviceFS();
@@ -7,5 +7,5 @@ export const config = {
7
7
  /**
8
8
  * Whether to sync atime updates immediately when reading from a file
9
9
  */
10
- syncOnRead: true,
10
+ updateOnRead: true,
11
11
  };
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
- this.dirty = true;
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
- if (config.syncOnRead) await this.sync();
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
- if (config.syncOnRead) this.syncSync();
562
+ this.syncSync();
561
563
  return bytesRead;
562
564
  }
563
565