MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / openSync

Method openSync

src/index.ts:592–612  ·  view source on GitHub ↗

* Open synchronously (without sync). * * `deferIndexRecovery` leaves the secondary indexes an interrupted bulk load * dropped for recoverIndexes to rebuild off this thread, instead of * rebuilding them here (#1887): for a caller on a watched event loop, which * then awaits {@l

(projectRoot: string, options: Pick<OpenOptions, 'readOnly'> & { deferIndexRecovery?: boolean } = {})

Source from the content-addressed store, hash-verified

590 * then awaits {@link recoverIndexes} before it relies on the project.
591 */
592 static openSync(projectRoot: string, options: Pick<OpenOptions, 'readOnly'> & { deferIndexRecovery?: boolean } = {}): CodeGraph {
593 const resolvedRoot = path.resolve(projectRoot);
594
595 // Check if initialized
596 if (!isInitialized(resolvedRoot)) {
597 throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`);
598 }
599
600 // Validate directory structure
601 const validation = validateDirectory(resolvedRoot);
602 if (!validation.valid) {
603 throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`);
604 }
605
606 // Open database
607 const dbPath = getDatabasePath(resolvedRoot);
608 const db = DatabaseConnection.open(dbPath, { readOnly: options.readOnly, deferIndexRecovery: options.deferIndexRecovery });
609 const queries = new QueryBuilder(db.getDb());
610
611 return new CodeGraph(db, queries, resolvedRoot);
612 }
613
614 /**
615 * Rebuild, on a worker thread, the secondary indexes an interrupted bulk

Callers 15

readFileInChunksFunction · 0.45
readSourceTextFunction · 0.45
readRegularFileSyncFunction · 0.45
writeRegularFileSyncFunction · 0.45
readBoundedSourceSyncFunction · 0.45
attemptFunction · 0.45
spawnDetachedDaemonFunction · 0.45
openMethod · 0.45
constructorMethod · 0.45
retryInitializeSyncMethod · 0.45
openToReadFunction · 0.45

Calls 7

isInitializedFunction · 0.90
validateDirectoryFunction · 0.90
getDatabasePathFunction · 0.90
getDbMethod · 0.80
resolveMethod · 0.65
openMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected