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>
This commit is contained in:
parent
d3f20a4725
commit
eadc3850fe
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user