diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-24 18:39:35 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-02-01 15:52:46 +0800 |
commit | eca93e631f4c080ca72a762bfa3b214aef3af48a (patch) | |
tree | b88e85739fe5fe9864765715908548e1c307e604 /src | |
parent | f5e287ba208b8d9eed3c850577ff9a46d9935d9a (diff) | |
download | android-node-v8-eca93e631f4c080ca72a762bfa3b214aef3af48a.tar.gz android-node-v8-eca93e631f4c080ca72a762bfa3b214aef3af48a.tar.bz2 android-node-v8-eca93e631f4c080ca72a762bfa3b214aef3af48a.zip |
fs: throw errors from fs.fsyncSync 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 | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index 6188da2448..3ffec4225b 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -739,7 +739,7 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) { CHECK_GE(argc, 2); CHECK(args[0]->IsInt32()); - const int fd = args[0]->As<Int32>()->Value(); + const int fd = args[0].As<Int32>()->Value(); if (args[1]->IsObject()) { // fdatasync(fd, req) CHECK_EQ(argc, 2); @@ -756,16 +756,21 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) { static void Fsync(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - CHECK(args[0]->IsInt32()); + const int argc = args.Length(); + CHECK_GE(argc, 2); - int fd = args[0]->Int32Value(); + CHECK(args[0]->IsInt32()); + const int fd = args[0].As<Int32>()->Value(); - if (args[1]->IsObject()) { - CHECK_EQ(args.Length(), 2); + if (args[1]->IsObject()) { // fsync(fd, req) + CHECK_EQ(argc, 2); AsyncCall(env, args, "fsync", UTF8, AfterNoArgs, uv_fs_fsync, fd); - } else { - SYNC_CALL(fsync, 0, fd) + } else { // fsync(fd, undefined, ctx) + CHECK_EQ(argc, 3); + fs_req_wrap req_wrap; + SyncCall(env, args[2], &req_wrap, "fsync", + uv_fs_fsync, fd); } } |