Skip to content

Commit f7c0a0b

Browse files
authored
fix: use fast glob streaming when collecting files (#2003)
* fix: use fast glob streaming when collecting files * fix: lower threshold * fix: adjust max files
1 parent f7ade37 commit f7c0a0b

File tree

1 file changed

+16
-3
lines changed
  • server/aws-lsp-codewhisperer/src/shared

1 file changed

+16
-3
lines changed

server/aws-lsp-codewhisperer/src/shared/utils.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,28 @@ export async function listFilesWithGitignore(directory: string): Promise<string[
533533
}
534534
}
535535

536-
const absolutePaths = await fg(['**/*'], {
536+
const absolutePaths: string[] = []
537+
let fileCount = 0
538+
const MAX_FILES = 500_000
539+
540+
const stream = fg.stream(['**/*'], {
537541
cwd: directory,
538542
dot: true,
539543
ignore: ignorePatterns,
540-
onlyFiles: false,
544+
onlyFiles: true,
541545
followSymbolicLinks: false,
542546
absolute: true,
543547
})
544-
return absolutePaths.slice(0, 500_000)
548+
549+
for await (const entry of stream) {
550+
if (fileCount >= MAX_FILES) {
551+
break
552+
}
553+
absolutePaths.push(entry.toString())
554+
fileCount++
555+
}
556+
557+
return absolutePaths
545558
}
546559

547560
export function getFileExtensionName(filepath: string): string {

0 commit comments

Comments
 (0)