Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5a0c19

Browse filesBrowse 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
Copy full SHA for e5a0c19

File tree

Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Collapse file

‎lib/internal/fs/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js
+10-12Lines 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
async function lchmod(path, mode) {
379-
if (O_SYMLINK !== undefined) {
380-
const fd = await open(path,
381-
O_WRONLY | O_SYMLINK);
382-
return fchmod(fd, mode).finally(fd.close.bind(fd));
383-
}
384-
throw new ERR_METHOD_NOT_IMPLEMENTED();
379+
if (O_SYMLINK === undefined)
380+
throw new ERR_METHOD_NOT_IMPLEMENTED();
381+
382+
const fd = await open(path, O_WRONLY | O_SYMLINK);
383+
return fchmod(fd, mode).finally(fd.close.bind(fd));
385384
}
386385

387386
async function lchown(path, uid, gid) {
388-
if (O_SYMLINK !== undefined) {
389-
const fd = await open(path,
390-
O_WRONLY | O_SYMLINK);
391-
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
392-
}
393-
throw new ERR_METHOD_NOT_IMPLEMENTED();
387+
if (O_SYMLINK === undefined)
388+
throw new ERR_METHOD_NOT_IMPLEMENTED();
389+
390+
const fd = await open(path, O_WRONLY | O_SYMLINK);
391+
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
394392
}
395393

396394
async function fchown(handle, uid, gid) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.