GeezerVison is showing github.com — fs: improve error performance of `lchownSync` · nodejs/node@4242cb7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/fs.js +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2010,9 +2010,11 @@ function lchownSync(path, uid, gid) { | 2010 | 2010 | path = getValidatedPath(path); | 2011 | 2011 | validateInteger(uid, 'uid', -1, kMaxUserId); | 2012 | 2012 | validateInteger(gid, 'gid', -1, kMaxUserId); | 2013 | | - const ctx = { path }; | 2014 | | - binding.lchown(pathModule.toNamespacedPath(path), uid, gid, undefined, ctx); | 2015 | | - handleErrorFromBinding(ctx); | | 2013 | + binding.lchown( | | 2014 | + pathModule.toNamespacedPath(path), | | 2015 | + uid, | | 2016 | + gid, | | 2017 | + ); | 2016 | 2018 | } | 2017 | 2019 |
| 2018 | 2020 | /** | |
Collapse file Copy file name to clipboardExpand all lines: src/node_file.cc +5-7Lines changed: 5 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2668,18 +2668,16 @@ static void LChown(const FunctionCallbackInfo<Value>& args) { | 2668 | 2668 | CHECK(IsSafeJsInt(args[2])); | 2669 | 2669 | const uv_gid_t gid = static_cast<uv_gid_t>(args[2].As<Integer>()->Value()); | 2670 | 2670 |
| 2671 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); | 2672 | | - if (req_wrap_async != nullptr) { // lchown(path, uid, gid, req) | | 2671 | + if (argc > 3) { // lchown(path, uid, gid, req) | | 2672 | + FSReqBase* req_wrap_async = GetReqWrap(args, 3); | 2673 | 2673 | FS_ASYNC_TRACE_BEGIN1( | 2674 | 2674 | UV_FS_LCHOWN, req_wrap_async, "path", TRACE_STR_COPY(*path)) | 2675 | 2675 | AsyncCall(env, req_wrap_async, args, "lchown", UTF8, AfterNoArgs, | 2676 | 2676 | uv_fs_lchown, *path, uid, gid); | 2677 | | - } else { // lchown(path, uid, gid, undefined, ctx) | 2678 | | - CHECK_EQ(argc, 5); | 2679 | | - FSReqWrapSync req_wrap_sync; | | 2677 | + } else { // lchown(path, uid, gid) | | 2678 | + FSReqWrapSync req_wrap_sync("lchown", *path); | 2680 | 2679 | FS_SYNC_TRACE_BEGIN(lchown); | 2681 | | - SyncCall(env, args[4], &req_wrap_sync, "lchown", | 2682 | | - uv_fs_lchown, *path, uid, gid); | | 2680 | + SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_lchown, *path, uid, gid); | 2683 | 2681 | FS_SYNC_TRACE_END(lchown); | 2684 | 2682 | } | 2685 | 2683 | } | |
Collapse file Copy file name to clipboardExpand all lines: typings/internalBinding/fs.d.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -117,6 +117,7 @@ declare namespace InternalFSBinding { | 117 | 117 | function lchown(path: string, uid: number, gid: number, req: FSReqCallback): void; | 118 | 118 | function lchown(path: string, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void; | 119 | 119 | function lchown(path: string, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>; | | 120 | + function lchown(path: string, uid: number, gid: number): void; | 120 | 121 |
| 121 | 122 | function link(existingPath: string, newPath: string, req: FSReqCallback): void; | 122 | 123 | function link(existingPath: string, newPath: string, req: undefined, ctx: FSSyncContext): void; | |
|