@@ -1377,7 +1377,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13771377 Isolate* isolate = env->isolate ();
13781378
13791379 const int argc = args.Length ();
1380- CHECK_GE (argc, 3 );
1380+ CHECK_GE (argc, 2 );
13811381
13821382 BufferValue src (isolate, args[0 ]);
13831383 CHECK_NOT_NULL (*src);
@@ -1395,8 +1395,8 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13951395 THROW_IF_INSUFFICIENT_PERMISSIONS (
13961396 env, permission::PermissionScope::kFileSystemWrite , dest_view);
13971397
1398- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1399- if ( req_wrap_async != nullptr ) { // link(src, dest, req)
1398+ if (argc > 2 ) { // link(src, dest, req)
1399+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
14001400 FS_ASYNC_TRACE_BEGIN2 (UV_FS_LINK,
14011401 req_wrap_async,
14021402 " src" ,
@@ -1406,11 +1406,9 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
14061406 AsyncDestCall (env, req_wrap_async, args, " link" , *dest, dest.length (), UTF8,
14071407 AfterNoArgs, uv_fs_link, *src, *dest);
14081408 } else { // link(src, dest)
1409- CHECK_EQ (argc, 4 );
1410- FSReqWrapSync req_wrap_sync;
1409+ FSReqWrapSync req_wrap_sync (" link" , *src, *dest);
14111410 FS_SYNC_TRACE_BEGIN (link);
1412- SyncCall (env, args[3 ], &req_wrap_sync, " link" ,
1413- uv_fs_link, *src, *dest);
1411+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_link, *src, *dest);
14141412 FS_SYNC_TRACE_END (link);
14151413 }
14161414}
0 commit comments