MCPcopy
hub / github.com/continuedev/continue / update

Method update

core/indexing/chunk/ChunkCodebaseIndex.ts:31–154  ·  view source on GitHub ↗
(
    tag: IndexTag,
    results: RefreshIndexResults,
    markComplete: MarkCompleteCallback,
    repoName: string | undefined,
  )

Source from the content-addressed store, hash-verified

29 ) {}
30
31 async *update(
32 tag: IndexTag,
33 results: RefreshIndexResults,
34 markComplete: MarkCompleteCallback,
35 repoName: string | undefined,
36 ): AsyncGenerator<IndexingProgressUpdate, any, unknown> {
37 const db = await SqliteDb.get();
38 await this.createTables(db);
39 const tagString = tagToString(tag);
40
41 // Check the remote cache
42 if (this.continueServerClient.connected) {
43 try {
44 const keys = results.compute.map(({ cacheKey }) => cacheKey);
45 const resp = await this.continueServerClient.getFromIndexCache(
46 keys,
47 "chunks",
48 repoName,
49 );
50
51 for (const [cacheKey, chunks] of Object.entries(resp.files)) {
52 await this.insertChunks(db, tagString, chunks);
53 }
54 results.compute = results.compute.filter(
55 (item) => !resp.files[item.cacheKey],
56 );
57 } catch (e) {
58 console.error("Failed to fetch from remote cache: ", e);
59 }
60 }
61
62 let accumulatedProgress = 0;
63
64 if (results.compute.length > 0) {
65 const filepath = results.compute[0].path;
66 const folderName = path.basename(path.dirname(filepath));
67
68 yield {
69 desc: `Chunking files in ${folderName}`,
70 status: "indexing",
71 progress: accumulatedProgress,
72 };
73 const chunks = await this.computeChunks(results.compute);
74 await this.insertChunks(db, tagString, chunks);
75 await markComplete(results.compute, IndexResultType.Compute);
76 }
77
78 // Add tag
79 for (const item of results.addTag) {
80 try {
81 await db.run(
82 `
83 INSERT INTO chunk_tags (chunkId, tag)
84 SELECT id, ? FROM chunks
85 WHERE cacheKey = ?
86 `,
87 [tagString, item.cacheKey],
88 );

Callers

nothing calls this directly

Calls 11

createTablesMethod · 0.95
insertChunksMethod · 0.95
computeChunksMethod · 0.95
tagToStringFunction · 0.85
markCompleteFunction · 0.85
getUriPathBasenameFunction · 0.85
errorMethod · 0.80
getMethod · 0.65
getFromIndexCacheMethod · 0.65
runMethod · 0.65
debugMethod · 0.45

Tested by

no test coverage detected