@@ -1519,21 +1519,20 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
1519
1519
Environment* env = Environment::GetCurrent (args);
1520
1520
1521
1521
const int argc = args.Length ();
1522
- CHECK_GE (argc, 2 );
1523
-
1524
- CHECK (args[0 ]->IsInt32 ());
1525
- const int fd = args[0 ].As <Int32>()->Value ();
1522
+ CHECK_GE (argc, 1 );
1526
1523
1527
- FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1528
- if (req_wrap_async != nullptr ) {
1524
+ const int fd = GetValidatedFd (env,args[0 ]);
1525
+
1526
+ if (argc > 1 ) { // fdatasync(fd, req)
1527
+ FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1528
+ CHECK_NOT_NULL (req_wrap_async);
1529
1529
FS_ASYNC_TRACE_BEGIN0 (UV_FS_FDATASYNC, req_wrap_async)
1530
1530
AsyncCall (env, req_wrap_async, args, " fdatasync" , UTF8, AfterNoArgs,
1531
1531
uv_fs_fdatasync, fd);
1532
- } else {
1533
- CHECK_EQ (argc, 3 );
1534
- FSReqWrapSync req_wrap_sync;
1532
+ } else { // fdatasync(fd)
1533
+ FSReqWrapSync req_wrap_sync (" fdatasync" );
1535
1534
FS_SYNC_TRACE_BEGIN (fdatasync);
1536
- SyncCall (env, args[ 2 ], &req_wrap_sync, " fdatasync " , uv_fs_fdatasync, fd);
1535
+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fdatasync, fd);
1537
1536
FS_SYNC_TRACE_END (fdatasync);
1538
1537
}
1539
1538
}
@@ -3254,7 +3253,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
3254
3253
SetMethod (isolate, target, " readFileUtf8" , ReadFileUtf8);
3255
3254
SetMethod (isolate, target, " readBuffers" , ReadBuffers);
3256
3255
SetMethod (isolate, target, " fdatasync" , Fdatasync);
3257
- SetMethod (isolate, target, " fdatasyncSync" , FdatasyncSync);
3258
3256
SetMethod (isolate, target, " fsync" , Fsync);
3259
3257
SetMethod (isolate, target, " rename" , Rename);
3260
3258
SetMethod (isolate, target, " ftruncate" , FTruncate);
0 commit comments