summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-01-24 09:37:52 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-02-01 15:52:40 +0800
commitf5e287ba208b8d9eed3c850577ff9a46d9935d9a (patch)
treed7cc63fb647561a427214d5c4695d40670020fc4 /src
parentb3a7df7c6dddcc4aaf2106d569a2a4c017e9699c (diff)
downloadandroid-node-v8-f5e287ba208b8d9eed3c850577ff9a46d9935d9a.tar.gz
android-node-v8-f5e287ba208b8d9eed3c850577ff9a46d9935d9a.tar.bz2
android-node-v8-f5e287ba208b8d9eed3c850577ff9a46d9935d9a.zip
fs: throw errors from fs.fdatasyncSync 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.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 10149b403e..6188da2448 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -735,16 +735,21 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
static void Fdatasync(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()) { // fdatasync(fd, req)
+ CHECK_EQ(argc, 2);
AsyncCall(env, args, "fdatasync", UTF8, AfterNoArgs,
uv_fs_fdatasync, fd);
- } else {
- SYNC_CALL(fdatasync, 0, fd)
+ } else { // fdatasync(fd, undefined, ctx)
+ CHECK_EQ(argc, 3);
+ fs_req_wrap req_wrap;
+ SyncCall(env, args[2], &req_wrap, "fdatasync",
+ uv_fs_fdatasync, fd);
}
}