@zenfs/core
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -73,4 +73,4 @@ import { checkOptions, isBackend, isBackendConfig } from './backends/backend.js'; | ||
config.checkAccess = !configuration.disableAccessChecks; | ||
config.syncOnRead = !configuration.onlySyncOnClose || !configuration.disableUpdateOnRead; | ||
config.syncOnWrite = !configuration.onlySyncOnClose; | ||
config.updateOnRead = !configuration.disableUpdateOnRead; | ||
config.syncImmediately = !configuration.onlySyncOnClose; | ||
if (configuration.addDevices) { | ||
@@ -77,0 +77,0 @@ const devfs = new DeviceFS(); |
@@ -7,9 +7,9 @@ export declare const config: { | ||
/** | ||
* Whether to sync atime updates immediately when reading from a file | ||
* Whether to mark a file as dirty after updating its `atime` when read from | ||
*/ | ||
syncOnRead: boolean; | ||
updateOnRead: boolean; | ||
/** | ||
* Whether to immediately sync when files are written to | ||
* Whether to immediately sync when files are changed | ||
*/ | ||
syncOnWrite: boolean; | ||
syncImmediately: boolean; | ||
/** | ||
@@ -16,0 +16,0 @@ * If a file's buffer is not large enough to store content when writing and the buffer can't be resized, reuse the buffer passed to write() |
@@ -7,9 +7,9 @@ export const config = { | ||
/** | ||
* Whether to sync atime updates immediately when reading from a file | ||
* Whether to mark a file as dirty after updating its `atime` when read from | ||
*/ | ||
syncOnRead: true, | ||
updateOnRead: true, | ||
/** | ||
* Whether to immediately sync when files are written to | ||
* Whether to immediately sync when files are changed | ||
*/ | ||
syncOnWrite: true, | ||
syncImmediately: true, | ||
/** | ||
@@ -16,0 +16,0 @@ * If a file's buffer is not large enough to store content when writing and the buffer can't be resized, reuse the buffer passed to write() |
@@ -292,3 +292,3 @@ import { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY, S_IFMT, size_max } from './emulation/constants.js'; | ||
this._truncate(length); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -298,3 +298,3 @@ } | ||
this._truncate(length); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -344,3 +344,3 @@ } | ||
const bytesWritten = this._write(buffer, offset, length, position); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -360,3 +360,3 @@ return bytesWritten; | ||
const bytesWritten = this._write(buffer, offset, length, position); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -372,3 +372,5 @@ return bytesWritten; | ||
} | ||
this.dirty = true; | ||
if (config.updateOnRead) { | ||
this.dirty = true; | ||
} | ||
this.stats.atimeMs = Date.now(); | ||
@@ -399,3 +401,3 @@ position ?? (position = this.position); | ||
const bytesRead = this._read(buffer, offset, length, position); | ||
if (config.syncOnRead) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -415,3 +417,3 @@ return { bytesRead, buffer }; | ||
const bytesRead = this._read(buffer, offset, length, position); | ||
if (config.syncOnRead) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -426,3 +428,3 @@ return bytesRead; | ||
this.stats.chmod(mode); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -436,3 +438,3 @@ } | ||
this.stats.chmod(mode); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -446,3 +448,3 @@ } | ||
this.stats.chown(uid, gid); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -456,3 +458,3 @@ } | ||
this.stats.chown(uid, gid); | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -467,3 +469,3 @@ } | ||
this.stats.mtime = mtime; | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
await this.sync(); | ||
@@ -478,3 +480,3 @@ } | ||
this.stats.mtime = mtime; | ||
if (config.syncOnWrite) | ||
if (config.syncImmediately) | ||
this.syncSync(); | ||
@@ -481,0 +483,0 @@ } |
{ | ||
"name": "@zenfs/core", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "A filesystem, anywhere", | ||
@@ -5,0 +5,0 @@ "funding": { |
@@ -166,4 +166,4 @@ import type { Backend, BackendConfiguration, FilesystemOf, SharedConfig } from './backends/backend.js'; | ||
config.checkAccess = !configuration.disableAccessChecks; | ||
config.syncOnRead = !configuration.onlySyncOnClose || !configuration.disableUpdateOnRead; | ||
config.syncOnWrite = !configuration.onlySyncOnClose; | ||
config.updateOnRead = !configuration.disableUpdateOnRead; | ||
config.syncImmediately = !configuration.onlySyncOnClose; | ||
@@ -170,0 +170,0 @@ if (configuration.addDevices) { |
@@ -8,10 +8,10 @@ export const config = { | ||
/** | ||
* Whether to sync atime updates immediately when reading from a file | ||
* Whether to mark a file as dirty after updating its `atime` when read from | ||
*/ | ||
syncOnRead: true, | ||
updateOnRead: true, | ||
/** | ||
* Whether to immediately sync when files are written to | ||
* Whether to immediately sync when files are changed | ||
*/ | ||
syncOnWrite: true, | ||
syncImmediately: true, | ||
@@ -18,0 +18,0 @@ /** |
@@ -444,3 +444,3 @@ import type { FileReadResult } from 'node:fs/promises'; | ||
this._truncate(length); | ||
if (config.syncOnWrite) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
} | ||
@@ -450,3 +450,3 @@ | ||
this._truncate(length); | ||
if (config.syncOnWrite) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
} | ||
@@ -499,3 +499,3 @@ | ||
const bytesWritten = this._write(buffer, offset, length, position); | ||
if (config.syncOnWrite) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
return bytesWritten; | ||
@@ -515,3 +515,3 @@ } | ||
const bytesWritten = this._write(buffer, offset, length, position); | ||
if (config.syncOnWrite) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
return bytesWritten; | ||
@@ -524,7 +524,13 @@ } | ||
} | ||
if (!isReadable(this.flag)) { | ||
throw new ErrnoError(Errno.EPERM, 'File not opened with a readable mode.'); | ||
} | ||
this.dirty = true; | ||
if (config.updateOnRead) { | ||
this.dirty = true; | ||
} | ||
this.stats.atimeMs = Date.now(); | ||
position ??= this.position; | ||
@@ -555,3 +561,3 @@ let end = position + length; | ||
const bytesRead = this._read(buffer, offset, length, position); | ||
if (config.syncOnRead) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
return { bytesRead, buffer }; | ||
@@ -571,3 +577,3 @@ } | ||
const bytesRead = this._read(buffer, offset, length, position); | ||
if (config.syncOnRead) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
return bytesRead; | ||
@@ -582,3 +588,3 @@ } | ||
this.stats.chmod(mode); | ||
if (config.syncOnWrite) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
} | ||
@@ -592,3 +598,3 @@ | ||
this.stats.chmod(mode); | ||
if (config.syncOnWrite) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
} | ||
@@ -602,3 +608,3 @@ | ||
this.stats.chown(uid, gid); | ||
if (config.syncOnWrite) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
} | ||
@@ -612,3 +618,3 @@ | ||
this.stats.chown(uid, gid); | ||
if (config.syncOnWrite) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
} | ||
@@ -623,3 +629,3 @@ | ||
this.stats.mtime = mtime; | ||
if (config.syncOnWrite) await this.sync(); | ||
if (config.syncImmediately) await this.sync(); | ||
} | ||
@@ -634,3 +640,3 @@ | ||
this.stats.mtime = mtime; | ||
if (config.syncOnWrite) this.syncSync(); | ||
if (config.syncImmediately) this.syncSync(); | ||
} | ||
@@ -637,0 +643,0 @@ |
871110
23135