deno/ext/node/polyfills/_fs/_fs_fdatasync.ts
Daniel Osvaldo R a941d3ff23
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
fix(ext/node): validate fd is integer on fsync and fdatasync (#30215)
2025-07-28 11:01:00 -04:00

30 lines
890 B
TypeScript

// Copyright 2018-2025 the Deno authors. MIT license.
import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { FsFile } from "ext:deno_fs/30_fs.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
import { validateInt32 } from "ext:deno_node/internal/validators.mjs";
import { primordials } from "ext:core/mod.js";
const { PromisePrototypeThen, SymbolFor } = primordials;
export function fdatasync(
fd: number,
callback: CallbackWithError,
) {
validateInt32(fd, "fd", 0);
PromisePrototypeThen(
new FsFile(fd, SymbolFor("Deno.internal.FsFile")).syncData(),
() => callback(null),
callback,
);
}
export function fdatasyncSync(fd: number) {
validateInt32(fd, "fd", 0);
new FsFile(fd, SymbolFor("Deno.internal.FsFile")).syncDataSync();
}
export const fdatasyncPromise = promisify(fdatasync) as (
fd: number,
) => Promise<void>;