* 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 } = {})
| 569 | * then awaits {@link recoverIndexes} before it relies on the project. |
| 570 | */ |
| 571 | static openSync(projectRoot: string, options: Pick<OpenOptions, 'readOnly'> & { deferIndexRecovery?: boolean } = {}): CodeGraph { |
| 572 | const resolvedRoot = path.resolve(projectRoot); |
| 573 | |
| 574 | // Check if initialized |
| 575 | if (!isInitialized(resolvedRoot)) { |
| 576 | throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`); |
| 577 | } |
| 578 | |
| 579 | // Validate directory structure |
| 580 | const validation = validateDirectory(resolvedRoot); |
| 581 | if (!validation.valid) { |
| 582 | throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`); |
| 583 | } |
| 584 | |
| 585 | // Open database |
| 586 | const dbPath = getDatabasePath(resolvedRoot); |
| 587 | const db = DatabaseConnection.open(dbPath, { readOnly: options.readOnly, deferIndexRecovery: options.deferIndexRecovery }); |
| 588 | const queries = new QueryBuilder(db.getDb()); |
| 589 | |
| 590 | return new CodeGraph(db, queries, resolvedRoot); |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * Rebuild, on a worker thread, the secondary indexes an interrupted bulk |
no test coverage detected