fs: close file descriptor of promisified truncate

Original PR:
  PR-URL: https://github.com/nodejs/node/pull/28858
  Reviewed-By: Rich Trott <rtrott@gmail.com>
  Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/34239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
João Reis authored and Shelley Vohr committed 2020-07-14 12:13:15 -07:00
1 parent 6db21cce30
commit 7aac9832f2
1 file changed
+2 -1
+2 -1
View File
@@ -305,7 +305,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) {