Skip to content

Commit

Permalink
apply nodejs#49913
Browse files Browse the repository at this point in the history
  • Loading branch information
pluris committed Oct 1, 2023
1 parent 70a8931 commit 1d42984
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ function fdatasync(fd, callback) {
* @returns {void}
*/
function fdatasyncSync(fd) {
syncFs.fdatasync(fd);
return binding.fdatasync(fd);
}

/**
Expand Down
20 changes: 9 additions & 11 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1519,21 +1519,20 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

const int argc = args.Length();
CHECK_GE(argc, 2);

CHECK(args[0]->IsInt32());
const int fd = args[0].As<Int32>()->Value();
CHECK_GE(argc, 1);

FSReqBase* req_wrap_async = GetReqWrap(args, 1);
if (req_wrap_async != nullptr) {
const int fd = GetValidatedFd(env,args[0]);

if (argc > 1) { // fdatasync(fd, req)
FSReqBase* req_wrap_async = GetReqWrap(args, 1);
CHECK_NOT_NULL(req_wrap_async);
FS_ASYNC_TRACE_BEGIN0(UV_FS_FDATASYNC, req_wrap_async)
AsyncCall(env, req_wrap_async, args, "fdatasync", UTF8, AfterNoArgs,
uv_fs_fdatasync, fd);
} else {
CHECK_EQ(argc, 3);
FSReqWrapSync req_wrap_sync;
} else { // fdatasync(fd)
FSReqWrapSync req_wrap_sync("fdatasync");
FS_SYNC_TRACE_BEGIN(fdatasync);
SyncCall(env, args[2], &req_wrap_sync, "fdatasync", uv_fs_fdatasync, fd);
SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_fdatasync, fd);
FS_SYNC_TRACE_END(fdatasync);
}
}
Expand Down Expand Up @@ -3254,7 +3253,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
SetMethod(isolate, target, "readFileUtf8", ReadFileUtf8);
SetMethod(isolate, target, "readBuffers", ReadBuffers);
SetMethod(isolate, target, "fdatasync", Fdatasync);
SetMethod(isolate, target, "fdatasyncSync", FdatasyncSync);
SetMethod(isolate, target, "fsync", Fsync);
SetMethod(isolate, target, "rename", Rename);
SetMethod(isolate, target, "ftruncate", FTruncate);
Expand Down
2 changes: 1 addition & 1 deletion typings/internalBinding/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ declare namespace InternalFSBinding {
function fdatasync(fd: number, req: FSReqCallback): void;
function fdatasync(fd: number, req: undefined, ctx: FSSyncContext): void;
function fdatasync(fd: number, usePromises: typeof kUsePromises): Promise<void>;
function fdatasyncSync(fd: number): void;
function fdatasync(fd: number): void;

function fstat(fd: number, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void;
function fstat(fd: number, useBigint: true, req: FSReqCallback<BigUint64Array>): void;
Expand Down

0 comments on commit 1d42984

Please sign in to comment.