Skip to content

Commit

Permalink
fs: close file descriptor of promisified truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocgreis committed Jul 30, 2019
1 parent 727631f commit 119682e
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 119682e

Please sign in to comment.