Fix file handle leak on empty chat info

This commit is contained in:
Cohee
2025-05-22 23:19:10 +03:00
parent 57b81be9ce
commit be54ef3dac

View File

@@ -368,7 +368,6 @@ async function checkChatIntegrity(filePath, integritySlug) {
*/ */
export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false) { export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false) {
return new Promise(async (res) => { return new Promise(async (res) => {
const fileStream = fs.createReadStream(pathToFile);
const stats = await fs.promises.stat(pathToFile); const stats = await fs.promises.stat(pathToFile);
const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`; const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`;
@@ -392,6 +391,7 @@ export async function getChatInfo(pathToFile, additionalData = {}, isGroup = fal
return; return;
} }
const fileStream = fs.createReadStream(pathToFile);
const rl = readline.createInterface({ const rl = readline.createInterface({
input: fileStream, input: fileStream,
crlfDelay: Infinity, crlfDelay: Infinity,