mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
6db21cce30
commit
7aac9832f2
1 file changed
+2
-1
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user