Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/node_file-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,27 @@ FSReqBase* GetReqWrap(const v8::FunctionCallbackInfo<v8::Value>& args,
int index,
bool use_bigint) {
v8::Local<v8::Value> value = args[index];
FSReqBase* result = nullptr;
if (value->IsObject()) {
return BaseObject::Unwrap<FSReqBase>(value.As<v8::Object>());
}

Realm* realm = Realm::GetCurrent(args);
BindingData* binding_data = realm->GetBindingData<BindingData>();

if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) {
if (use_bigint) {
return FSReqPromise<AliasedBigInt64Array>::New(binding_data, use_bigint);
} else {
return FSReqPromise<AliasedFloat64Array>::New(binding_data, use_bigint);
result = BaseObject::Unwrap<FSReqBase>(value.As<v8::Object>());
} else {
Realm* realm = Realm::GetCurrent(args);
BindingData* binding_data = realm->GetBindingData<BindingData>();

if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) {
if (use_bigint) {
result =
FSReqPromise<AliasedBigInt64Array>::New(binding_data, use_bigint);
} else {
result =
FSReqPromise<AliasedFloat64Array>::New(binding_data, use_bigint);
}
}
}
return nullptr;
if (result != nullptr) {
result->SetReturnValue(args);
}
return result;
}

// Returns nullptr if the operation fails from the start.
Expand All @@ -320,10 +326,7 @@ FSReqBase* AsyncDestCall(Environment* env, FSReqBase* req_wrap,
uv_req->path = nullptr;
after(uv_req); // after may delete req_wrap if there is an error
req_wrap = nullptr;
} else {
req_wrap->SetReturnValue(args);
}

return req_wrap;
}

Expand Down
2 changes: 0 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2473,8 +2473,6 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
uv_req->path = nullptr;
AfterInteger(uv_req); // after may delete req_wrap_async if there is
// an error
} else {
req_wrap_async->SetReturnValue(args);
}
} else { // write(fd, string, pos, enc, undefined, ctx)
CHECK_EQ(argc, 6);
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/permission/fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ const relativeProtectedFolder = process.env.RELATIVEBLOCKEDFOLDER;
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
}));
assert.rejects(async () => {
await fs.promises.mkdtemp(path.join(blockedFolder, 'any-folder'));
}, {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemWrite',
});
}

// fs.mkdtempDisposableSync
Expand Down
Loading