diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-24 22:18:37 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-01 15:52:52 +0800 |
commit | 776f6cdfc4d7f8b3e0eaff6bd71571ebd937609b (patch) | |
tree | e84b4117b8b4a6e90dcf045ead8ce1215a688224 /src | |
parent | eca93e631f4c080ca72a762bfa3b214aef3af48a (diff) | |
download | android-node-v8-776f6cdfc4d7f8b3e0eaff6bd71571ebd937609b.tar.gz android-node-v8-776f6cdfc4d7f8b3e0eaff6bd71571ebd937609b.tar.bz2 android-node-v8-776f6cdfc4d7f8b3e0eaff6bd71571ebd937609b.zip |
fs: throw errors from fs.unlinkSync in JS
PR-URL: https://github.com/nodejs/node/pull/18348
Refs: https://github.com/nodejs/node/issues/18106
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_file.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index 3ffec4225b..93f54aed23 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -777,17 +777,21 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) { static void Unlink(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - CHECK_GE(args.Length(), 1); + const int argc = args.Length(); + CHECK_GE(argc, 2); BufferValue path(env->isolate(), args[0]); CHECK_NE(*path, nullptr); - if (args[1]->IsObject()) { - CHECK_EQ(args.Length(), 2); + if (args[1]->IsObject()) { // unlink(fd, req) + CHECK_EQ(argc, 2); AsyncCall(env, args, "unlink", UTF8, AfterNoArgs, uv_fs_unlink, *path); - } else { - SYNC_CALL(unlink, *path, *path) + } else { // unlink(fd, undefined, ctx) + CHECK_EQ(argc, 3); + fs_req_wrap req_wrap; + SyncCall(env, args[2], &req_wrap, "unlink", + uv_fs_unlink, *path); } } |