Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fs: improve error performance of chownSync
  • Loading branch information
anonrig committed Sep 26, 2023
commit 8437da55be83814a1af15fab1c38dab663bf7743
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