@@ -1342,7 +1342,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13421342 Isolate* isolate = env->isolate ();
13431343
13441344 const int argc = args.Length ();
1345- CHECK_GE (argc, 3 );
1345+ CHECK_GE (argc, 2 );
13461346
13471347 BufferValue src (isolate, args[0 ]);
13481348 CHECK_NOT_NULL (*src);
@@ -1360,8 +1360,8 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13601360 THROW_IF_INSUFFICIENT_PERMISSIONS (
13611361 env, permission::PermissionScope::kFileSystemWrite , dest_view);
13621362
1363- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1364- if ( req_wrap_async != nullptr ) { // link(src, dest, req)
1363+ if (argc > 2 ) { // link(src, dest, req)
1364+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
13651365 FS_ASYNC_TRACE_BEGIN2 (UV_FS_LINK,
13661366 req_wrap_async,
13671367 " src" ,
@@ -1371,11 +1371,9 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13711371 AsyncDestCall (env, req_wrap_async, args, " link" , *dest, dest.length (), UTF8,
13721372 AfterNoArgs, uv_fs_link, *src, *dest);
13731373 } else { // link(src, dest)
1374- CHECK_EQ (argc, 4 );
1375- FSReqWrapSync req_wrap_sync;
1374+ FSReqWrapSync req_wrap_sync (" link" , *src, *dest);
13761375 FS_SYNC_TRACE_BEGIN (link);
1377- SyncCall (env, args[3 ], &req_wrap_sync, " link" ,
1378- uv_fs_link, *src, *dest);
1376+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_link, *src, *dest);
13791377 FS_SYNC_TRACE_END (link);
13801378 }
13811379}
0 commit comments