diff options
author | João Reis <reis@janeasystems.com> | 2019-07-30 07:45:31 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-10 19:21:30 -0700 |
commit | eadc3850fe496506847a25a09f01e3c8238d177a (patch) | |
tree | dc682a7b0b327b3ddac2b9078511cbd26bc92363 /lib/internal/fs/promises.js | |
parent | d3f20a47255a0f88fa85ee4f9c18a77aeb8f7475 (diff) | |
download | android-node-v8-eadc3850fe496506847a25a09f01e3c8238d177a.tar.gz android-node-v8-eadc3850fe496506847a25a09f01e3c8238d177a.tar.bz2 android-node-v8-eadc3850fe496506847a25a09f01e3c8238d177a.zip |
fs: close file descriptor of promisified truncate
PR-URL: https://github.com/nodejs/node/pull/28858
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib/internal/fs/promises.js')
-rw-r--r-- | lib/internal/fs/promises.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index 42dbbcc361..d807cb71f7 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -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) { |