fix(core): resolve EISDIR errors during file processing (#21527) (#27041)

This commit is contained in:
PROTHAM
2026-05-15 02:51:57 +05:30
committed by GitHub
parent a6ed2cc5e3
commit 2151653133
2 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -199,8 +199,8 @@ ${finalExclusionPatternsForDescription
const fullPath = path.join(dir, normalizedP);
let exists = false;
try {
await fsPromises.access(fullPath);
exists = true;
const st = await fsPromises.stat(fullPath);
exists = st.isFile();
} catch {
exists = false;
}
+4 -1
View File
@@ -15,6 +15,7 @@ import { ToolErrorType } from '../tools/tool-error.js';
import { BINARY_EXTENSIONS } from './ignorePatterns.js';
import { createRequire as createModuleRequire } from 'node:module';
import { debugLogger } from './debugLogger.js';
import {
DEFAULT_MAX_LINES_TEXT_FILE,
MAX_LINE_LENGTH_TEXT_FILE,
@@ -350,7 +351,9 @@ export async function isEmpty(filePath: string): Promise<boolean> {
*/
export async function isBinaryFile(filePath: string): Promise<boolean> {
try {
return await isBinaryFileCheck(filePath);
const stats = await fsPromises.stat(filePath);
if (!stats.isFile()) return false;
return await isBinaryFileCheck(filePath, stats.size);
} catch (error) {
debugLogger.warn(
`Failed to check if file is binary: ${filePath}`,