@@ -1519,43 +1519,24 @@ 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
}
1540
1539
1541
- static void FdatasyncSync (const FunctionCallbackInfo<Value>& args) {
1542
- Environment* env = Environment::GetCurrent (args);
1543
-
1544
- CHECK_EQ (args.Length (), 1 );
1545
-
1546
- const int fd = GetValidatedFd (env, args[0 ]);
1547
- if (fd == (1 << 30 )) return ;
1548
-
1549
- uv_fs_t req;
1550
- auto make = OnScopeLeave ([&req]() { uv_fs_req_cleanup (&req); });
1551
- FS_SYNC_TRACE_BEGIN (fdatasync);
1552
- int err = uv_fs_fdatasync (nullptr , &req, fd, nullptr );
1553
- FS_SYNC_TRACE_END (fdatasync);
1554
- if (err < 0 ) {
1555
- return env->ThrowUVException (err, " fdatasync" );
1556
- }
1557
- }
1558
-
1559
1540
static void Fsync (const FunctionCallbackInfo<Value>& args) {
1560
1541
Environment* env = Environment::GetCurrent (args);
1561
1542
@@ -3254,7 +3235,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
3254
3235
SetMethod (isolate, target, " readFileUtf8" , ReadFileUtf8);
3255
3236
SetMethod (isolate, target, " readBuffers" , ReadBuffers);
3256
3237
SetMethod (isolate, target, " fdatasync" , Fdatasync);
3257
- SetMethod (isolate, target, " fdatasyncSync" , FdatasyncSync);
3258
3238
SetMethod (isolate, target, " fsync" , Fsync);
3259
3239
SetMethod (isolate, target, " rename" , Rename);
3260
3240
SetMethod (isolate, target, " ftruncate" , FTruncate);
@@ -3374,7 +3354,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
3374
3354
registry->Register (ReadFileUtf8);
3375
3355
registry->Register (ReadBuffers);
3376
3356
registry->Register (Fdatasync);
3377
- registry->Register (FdatasyncSync);
3378
3357
registry->Register (Fsync);
3379
3358
registry->Register (Rename);
3380
3359
registry->Register (FTruncate);
0 commit comments