Skip to content

Commit

Permalink
fs: close file descriptor of promisified truncate
Browse files Browse the repository at this point in the history
PR-URL: #28858
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
joaocgreis authored and Trott committed Aug 11, 2019
1 parent d3f20a4 commit eadc385
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ async function rename(oldPath, newPath) {
}

async function truncate(path, len = 0) {
return ftruncate(await open(path, 'r+'), len);
const fd = await open(path, 'r+');
return ftruncate(fd, len).finally(fd.close.bind(fd));
}

async function ftruncate(handle, len = 0) {
Expand Down

0 comments on commit eadc385

Please sign in to comment.