refactor: use sequential processing for directory file diffs

Address PR review feedback: replace Promise.all with sequential for...of
loop to avoid exhausting file descriptors when processing directories
with many files.
This commit is contained in:
Tony Nekola
2025-12-24 23:34:44 +02:00
parent 8f2d134d03
commit b0ce01d008

View File

@@ -77,10 +77,12 @@ Binary file ${cleanPath} added
// Empty directory // Empty directory
return createNewFileDiff(cleanPath, '040000', ['[Empty directory]']); return createNewFileDiff(cleanPath, '040000', ['[Empty directory]']);
} }
// Generate diffs for all files in the directory // Generate diffs for all files in the directory sequentially
const diffs = await Promise.all( // Using sequential processing to avoid exhausting file descriptors on large directories
filesInDir.map((filePath) => generateSyntheticDiffForNewFile(basePath, filePath)) const diffs: string[] = [];
); for (const filePath of filesInDir) {
diffs.push(await generateSyntheticDiffForNewFile(basePath, filePath));
}
return diffs.join(''); return diffs.join('');
} }