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