From be54ef3dacfc6706992b2ec0d5fbc9ee5ef49d85 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 22 May 2025 23:19:10 +0300 Subject: [PATCH] Fix file handle leak on empty chat info --- src/endpoints/chats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/endpoints/chats.js b/src/endpoints/chats.js index 6fe6ab13f..34bc9fd14 100644 --- a/src/endpoints/chats.js +++ b/src/endpoints/chats.js @@ -368,7 +368,6 @@ async function checkChatIntegrity(filePath, integritySlug) { */ export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false) { return new Promise(async (res) => { - const fileStream = fs.createReadStream(pathToFile); const stats = await fs.promises.stat(pathToFile); const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`; @@ -392,6 +391,7 @@ export async function getChatInfo(pathToFile, additionalData = {}, isGroup = fal return; } + const fileStream = fs.createReadStream(pathToFile); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity,