file read error handling

This commit is contained in:
Test 2024-09-20 10:35:20 -07:00
parent 5070f6ad8b
commit d055e2bc92
4 changed files with 26 additions and 10 deletions

View file

@ -13,10 +13,9 @@ export async function requestFilesFromRepoMap(
const llm = getModelByRole(config, "repoMapFileSelection") ?? defaultLlm;
// Only supported for Claude models right now
// TODO: Uncomment
// if (!llm.model.toLowerCase().includes("claude")) {
// return [];
// }
if (!llm.model.toLowerCase().includes("claude")) {
return [];
}
try {
const repoMap = await generateRepoMap(llm, ide, {

View file

@ -411,7 +411,7 @@ class ChromiumCrawler {
for (const link of linkGroup) {
enqueuedLinkCount++;
console.log({ enqueuedLinkCount, url: this.startUrl });
console.log({ enqueuedLinkCount, url: this.startUrl.toString() });
if (enqueuedLinkCount <= this.maxRequestsPerCrawl) {
yield* this.crawlSitePages(page, new URL(link), visitedLinks);
}

View file

@ -93,18 +93,35 @@ class RepoMapGenerator {
): Promise<void> {
for (const [absolutePath, signatures] of Object.entries(groupedByPath)) {
const content = await this.processFile(absolutePath, signatures);
await this.writeToStream(content);
if (content) {
await this.writeToStream(content);
}
}
}
private async processFile(
absolutePath: string,
signatures: string[],
): Promise<string> {
): Promise<string | undefined> {
const workspaceDir =
this.repoMapDirs.find((dir) => absolutePath.startsWith(dir)) || "";
const relativePath = path.relative(workspaceDir, absolutePath);
const fileContent = await fs.promises.readFile(absolutePath, "utf8");
let fileContent: string;
try {
fileContent = await fs.promises.readFile(absolutePath, "utf8");
} catch (err) {
console.error(
"Failed to read file:\n" +
` Path: ${absolutePath}\n` +
` Error: ${err instanceof Error ? err.message : String(err)}`,
);
return;
}
const filteredSignatures = signatures.filter(
(signature) => signature.trim() !== fileContent.trim(),
);

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.214",
"version": "0.9.211",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.214",
"version": "0.9.211",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",