mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
fs: refactor promises version of lchown and lchmod
Check for platform support first to save a level of indentation. PR-URL: https://github.com/nodejs/node/pull/20551 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
1 parent
6ce589f7f4
commit
e5a0c197bd
1 file changed
+10
-12
+10
-12
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user