Skip to content

Commit

Permalink
fixup! fs: improve error performance of chownSync
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 26, 2023
1 parent a38a542 commit 8437da5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions benchmark/fs/bench-chownSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const fs = require('fs');
const tmpdir = require('../../test/common/tmpdir');
tmpdir.refresh();

// Windows does not have `getuid` or `getgid`.
if (process.platform === 'win32') {
return;
}

const tmpfile = tmpdir.resolve(`.existing-file-${process.pid}`);
fs.writeFileSync(tmpfile, 'this-is-for-a-benchmark', 'utf8');

Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,7 @@ static void ChownSync(const FunctionCallbackInfo<Value>& args) {
const uv_gid_t gid = static_cast<uv_gid_t>(args[2].As<Integer>()->Value());

uv_fs_t req;
auto make = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); });
auto cleanup = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); });
FS_SYNC_TRACE_BEGIN(chown);
int err = uv_fs_chown(nullptr, &req, *path, uid, gid, nullptr);
FS_SYNC_TRACE_END(chown);
Expand Down

0 comments on commit 8437da5

Please sign in to comment.