diff --git a/.changeset/spicy-pumas-kneel.md b/.changeset/spicy-pumas-kneel.md new file mode 100644 index 00000000000..51003644a42 --- /dev/null +++ b/.changeset/spicy-pumas-kneel.md @@ -0,0 +1,6 @@ +--- +"@effect/platform-node-shared": patch +"@effect/platform": patch +--- + +Addition of `sync` property to `FileSystem.File` representing the `fsync` syscall. diff --git a/packages/platform-node-shared/src/internal/fileSystem.ts b/packages/platform-node-shared/src/internal/fileSystem.ts index 3fb5cc86660..0370e9b2080 100644 --- a/packages/platform-node-shared/src/internal/fileSystem.ts +++ b/packages/platform-node-shared/src/internal/fileSystem.ts @@ -210,6 +210,12 @@ const makeFile = (() => { handleBadArgument("truncate") ) + const nodeSync = effectify( + NFS.fsync, + handleErrnoException("FileSystem", "sync"), + handleBadArgument("sync") + ) + const nodeWriteFactory = (method: string) => effectify( NFS.write, @@ -236,6 +242,10 @@ const makeFile = (() => { return Effect.map(nodeStat(this.fd), makeFileInfo) } + get sync() { + return nodeSync(this.fd) + } + seek(offset: FileSystem.SizeInput, from: FileSystem.SeekMode) { const offsetSize = FileSystem.Size(offset) return this.semaphore.withPermits(1)( diff --git a/packages/platform/src/FileSystem.ts b/packages/platform/src/FileSystem.ts index db9ed8f5897..36c142bd4cc 100644 --- a/packages/platform/src/FileSystem.ts +++ b/packages/platform/src/FileSystem.ts @@ -491,6 +491,7 @@ export interface File { readonly fd: File.Descriptor readonly stat: Effect.Effect readonly seek: (offset: SizeInput, from: SeekMode) => Effect.Effect + readonly sync: Effect.Effect readonly read: (buffer: Uint8Array) => Effect.Effect readonly readAlloc: (size: SizeInput) => Effect.Effect, PlatformError> readonly truncate: (length?: SizeInput) => Effect.Effect