MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / indexAll

Method indexAll

src/codegraph/indexer.ts:43–141  ·  view source on GitHub ↗
(opts: IndexerOptions = {})

Source from the content-addressed store, hash-verified

41 constructor(private db: CodeGraphDB, private rootDir: string) {}
42
43 async indexAll(opts: IndexerOptions = {}): Promise<IndexResult> {
44 const start = Date.now();
45 const filesOnDisk = new Set<string>();
46 const candidates: string[] = [];
47
48 await this.walk(this.rootDir, (file) => {
49 filesOnDisk.add(file);
50 candidates.push(file);
51 });
52
53 let scanned = 0;
54 let indexed = 0;
55 let skipped = 0;
56 let totalSymbols = 0;
57 const total = candidates.length;
58
59 for (const filePath of candidates) {
60 if (opts.signal?.aborted) {
61 logger.info('Indexing cancelled by signal');
62 break;
63 }
64 scanned++;
65 opts.onProgress?.({ processed: scanned, total, currentFile: path.relative(this.rootDir, filePath) });
66
67 try {
68 const stat = await fs.stat(filePath);
69 if (!stat.isFile() || stat.size > MAX_FILE_SIZE) {
70 skipped++;
71 continue;
72 }
73 const lang = detectLanguage(filePath);
74 if (!lang) {
75 skipped++;
76 continue;
77 }
78
79 // Quick skip: same mtime+size means content unchanged
80 if (!opts.force && this.db.isFileFresh(filePath, stat.mtimeMs, stat.size, null)) {
81 skipped++;
82 continue;
83 }
84
85 // Read content + check binary
86 const buf = await fs.readFile(filePath);
87 if (isBinaryBuffer(buf)) {
88 skipped++;
89 continue;
90 }
91 const contentHash = crypto.createHash('sha256').update(buf).digest('hex').slice(0, 16);
92
93 // Re-check freshness with hash now that we have it
94 if (!opts.force && this.db.isFileFresh(filePath, stat.mtimeMs, stat.size, contentHash)) {
95 skipped++;
96 continue;
97 }
98
99 const source = buf.toString('utf-8');
100 const symbols = await extractSymbols(filePath, source);

Callers 3

handleSlashCommandFunction · 0.95
codegraph.test.tsFile · 0.80
index.tsFile · 0.80

Calls 14

walkMethod · 0.95
detectLanguageFunction · 0.85
isBinaryBufferFunction · 0.85
extractSymbolsFunction · 0.85
addMethod · 0.80
infoMethod · 0.80
isFileFreshMethod · 0.80
updateMethod · 0.80
replaceFileSymbolsMethod · 0.80
debugMethod · 0.80
removeFileMethod · 0.80
setMetaMethod · 0.80

Tested by

no test coverage detected