@@ -367,19 +367,24 @@ static void OpenDir(const FunctionCallbackInfo<Value>& args) {
367
367
368
368
BufferValue path (isolate, args[0 ]);
369
369
CHECK_NOT_NULL (*path);
370
- THROW_IF_INSUFFICIENT_PERMISSIONS (
371
- env, permission::PermissionScope::kFileSystemRead , path.ToStringView ());
372
370
373
371
const enum encoding encoding = ParseEncoding (isolate, args[1 ], UTF8);
374
372
375
373
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
376
374
if (req_wrap_async != nullptr ) { // openDir(path, encoding, req)
375
+ ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS (
376
+ env,
377
+ req_wrap_async,
378
+ permission::PermissionScope::kFileSystemRead ,
379
+ path.ToStringView ());
377
380
FS_DIR_ASYNC_TRACE_BEGIN1 (
378
381
UV_FS_OPENDIR, req_wrap_async, " path" , TRACE_STR_COPY (*path))
379
382
AsyncCall (env, req_wrap_async, args, " opendir" , encoding, AfterOpenDir,
380
383
uv_fs_opendir, *path);
381
384
} else { // openDir(path, encoding, undefined, ctx)
382
385
CHECK_EQ (argc, 4 );
386
+ THROW_IF_INSUFFICIENT_PERMISSIONS (
387
+ env, permission::PermissionScope::kFileSystemRead , path.ToStringView ());
383
388
FSReqWrapSync req_wrap_sync;
384
389
FS_DIR_SYNC_TRACE_BEGIN (opendir);
385
390
int result = SyncCall (env, args[3 ], &req_wrap_sync, " opendir" ,
0 commit comments