Skip to content

Commit

Permalink
fs: refactor promises version of lchown and lchmod
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and MylesBorins committed May 22, 2018
1 parent 6ce589f commit e5a0c19
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,19 @@ async function chmod(path, mode) {
}

async function lchmod(path, mode) {
if (O_SYMLINK !== undefined) {
const fd = await open(path,
O_WRONLY | O_SYMLINK);
return fchmod(fd, mode).finally(fd.close.bind(fd));
}
throw new ERR_METHOD_NOT_IMPLEMENTED();
if (O_SYMLINK === undefined)
throw new ERR_METHOD_NOT_IMPLEMENTED();

const fd = await open(path, O_WRONLY | O_SYMLINK);
return fchmod(fd, mode).finally(fd.close.bind(fd));
}

async function lchown(path, uid, gid) {
if (O_SYMLINK !== undefined) {
const fd = await open(path,
O_WRONLY | O_SYMLINK);
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
}
throw new ERR_METHOD_NOT_IMPLEMENTED();
if (O_SYMLINK === undefined)
throw new ERR_METHOD_NOT_IMPLEMENTED();

const fd = await open(path, O_WRONLY | O_SYMLINK);
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
}

async function fchown(handle, uid, gid) {
Expand Down

0 comments on commit e5a0c19

Please sign in to comment.