mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
fs: improve error performance of lchownSync
PR-URL: https://github.com/nodejs/node/pull/49962 Refs: https://github.com/nodejs/performance/issues/106 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
1 parent
89e7878e44
commit
4242cb7d7f
3 files changed
+11
-10
No files matched your search
@@ -2010,9 +2010,11 @@ function lchownSync(path, uid, gid) {
|
||||
path = getValidatedPath(path);
|
||||
validateInteger(uid, 'uid', -1, kMaxUserId);
|
||||
validateInteger(gid, 'gid', -1, kMaxUserId);
|
||||
const ctx = { path };
|
||||
binding.lchown(pathModule.toNamespacedPath(path), uid, gid, undefined, ctx);
|
||||
handleErrorFromBinding(ctx);
|
||||
binding.lchown(
|
||||
pathModule.toNamespacedPath(path),
|
||||
uid,
|
||||
gid,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-7
@@ -2668,18 +2668,16 @@ static void LChown(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(IsSafeJsInt(args[2]));
|
||||
const uv_gid_t gid = static_cast<uv_gid_t>(args[2].As<Integer>()->Value());
|
||||
|
||||
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
|
||||
if (req_wrap_async != nullptr) { // lchown(path, uid, gid, req)
|
||||
if (argc > 3) { // lchown(path, uid, gid, req)
|
||||
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
|
||||
FS_ASYNC_TRACE_BEGIN1(
|
||||
UV_FS_LCHOWN, req_wrap_async, "path", TRACE_STR_COPY(*path))
|
||||
AsyncCall(env, req_wrap_async, args, "lchown", UTF8, AfterNoArgs,
|
||||
uv_fs_lchown, *path, uid, gid);
|
||||
} else { // lchown(path, uid, gid, undefined, ctx)
|
||||
CHECK_EQ(argc, 5);
|
||||
FSReqWrapSync req_wrap_sync;
|
||||
} else { // lchown(path, uid, gid)
|
||||
FSReqWrapSync req_wrap_sync("lchown", *path);
|
||||
FS_SYNC_TRACE_BEGIN(lchown);
|
||||
SyncCall(env, args[4], &req_wrap_sync, "lchown",
|
||||
uv_fs_lchown, *path, uid, gid);
|
||||
SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_lchown, *path, uid, gid);
|
||||
FS_SYNC_TRACE_END(lchown);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -117,6 +117,7 @@ declare namespace InternalFSBinding {
|
||||
function lchown(path: string, uid: number, gid: number, req: FSReqCallback): void;
|
||||
function lchown(path: string, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void;
|
||||
function lchown(path: string, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>;
|
||||
function lchown(path: string, uid: number, gid: number): void;
|
||||
|
||||
function link(existingPath: string, newPath: string, req: FSReqCallback): void;
|
||||
function link(existingPath: string, newPath: string, req: undefined, ctx: FSSyncContext): void;
|
||||
|
||||
Reference in new issue
Block a user