Skip to content

Commit e5a0c19

Browse files
cjihrigMylesBorins
authored andcommitted
fs: refactor promises version of lchown and lchmod
Check for platform support first to save a level of indentation. PR-URL: #20551 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 6ce589f commit e5a0c19

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

‎lib/internal/fs/promises.js‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,21 +376,19 @@ async function chmod(path, mode) {
376376
}
377377

378378
asyncfunctionlchmod(path,mode){
379-
if(O_SYMLINK!==undefined){
380-
constfd=awaitopen(path,
381-
O_WRONLY|O_SYMLINK);
382-
returnfchmod(fd,mode).finally(fd.close.bind(fd));
383-
}
384-
thrownewERR_METHOD_NOT_IMPLEMENTED();
379+
if(O_SYMLINK===undefined)
380+
thrownewERR_METHOD_NOT_IMPLEMENTED();
381+
382+
constfd=awaitopen(path,O_WRONLY|O_SYMLINK);
383+
returnfchmod(fd,mode).finally(fd.close.bind(fd));
385384
}
386385

387386
asyncfunctionlchown(path,uid,gid){
388-
if(O_SYMLINK!==undefined){
389-
constfd=awaitopen(path,
390-
O_WRONLY|O_SYMLINK);
391-
returnfchown(fd,uid,gid).finally(fd.close.bind(fd));
392-
}
393-
thrownewERR_METHOD_NOT_IMPLEMENTED();
387+
if(O_SYMLINK===undefined)
388+
thrownewERR_METHOD_NOT_IMPLEMENTED();
389+
390+
constfd=awaitopen(path,O_WRONLY|O_SYMLINK);
391+
returnfchown(fd,uid,gid).finally(fd.close.bind(fd));
394392
}
395393

396394
asyncfunctionfchown(handle,uid,gid){

0 commit comments

Comments
 (0)