GeezerVison is showing github.com — fs: improve error performance of `lchownSync` · nodejs/node@6eeaa02
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 |
|---|
@@ -2012,9 +2012,11 @@ function lchownSync(path, uid, gid) { | 2012 | 2012 | path = getValidatedPath(path); | 2013 | 2013 | validateInteger(uid, 'uid', -1, kMaxUserId); | 2014 | 2014 | validateInteger(gid, 'gid', -1, kMaxUserId); | 2015 | | - const ctx = { path }; | 2016 | | - binding.lchown(pathModule.toNamespacedPath(path), uid, gid, undefined, ctx); | 2017 | | - handleErrorFromBinding(ctx); | | 2015 | + binding.lchown( | | 2016 | + pathModule.toNamespacedPath(path), | | 2017 | + uid, | | 2018 | + gid, | | 2019 | + ); | 2018 | 2020 | } | 2019 | 2021 |
| 2020 | 2022 | /** | |
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 |
|---|
@@ -2633,18 +2633,16 @@ static void LChown(const FunctionCallbackInfo<Value>& args) { | 2633 | 2633 | CHECK(IsSafeJsInt(args[2])); | 2634 | 2634 | const uv_gid_t gid = static_cast<uv_gid_t>(args[2].As<Integer>()->Value()); | 2635 | 2635 |
| 2636 | | - FSReqBase* req_wrap_async = GetReqWrap(args, 3); | 2637 | | - if (req_wrap_async != nullptr) { // lchown(path, uid, gid, req) | | 2636 | + if (argc > 3) { // lchown(path, uid, gid, req) | | 2637 | + FSReqBase* req_wrap_async = GetReqWrap(args, 3); | 2638 | 2638 | FS_ASYNC_TRACE_BEGIN1( | 2639 | 2639 | UV_FS_LCHOWN, req_wrap_async, "path", TRACE_STR_COPY(*path)) | 2640 | 2640 | AsyncCall(env, req_wrap_async, args, "lchown", UTF8, AfterNoArgs, | 2641 | 2641 | uv_fs_lchown, *path, uid, gid); | 2642 | | - } else { // lchown(path, uid, gid, undefined, ctx) | 2643 | | - CHECK_EQ(argc, 5); | 2644 | | - FSReqWrapSync req_wrap_sync; | | 2642 | + } else { // lchown(path, uid, gid) | | 2643 | + FSReqWrapSync req_wrap_sync("lchown", *path); | 2645 | 2644 | FS_SYNC_TRACE_BEGIN(lchown); | 2646 | | - SyncCall(env, args[4], &req_wrap_sync, "lchown", | 2647 | | - uv_fs_lchown, *path, uid, gid); | | 2645 | + SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_lchown, *path, uid, gid); | 2648 | 2646 | FS_SYNC_TRACE_END(lchown); | 2649 | 2647 | } | 2650 | 2648 | } | |
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; | |
|