(paths: string[])
| 722 | } |
| 723 | |
| 724 | public async refreshCodebaseIndex(paths: string[]) { |
| 725 | if (!this.indexingCancellationController.signal.aborted) { |
| 726 | this.indexingCancellationController.abort(); |
| 727 | } |
| 728 | const localController = new AbortController(); |
| 729 | this.indexingCancellationController = localController; |
| 730 | |
| 731 | for await (const update of this.waitForDBIndex()) { |
| 732 | this.updateProgress(update); |
| 733 | } |
| 734 | |
| 735 | await IndexLock.lock(paths.join(", ")); // acquire the index lock to prevent multiple windows to begin indexing |
| 736 | const indexLockTimestampUpdateInterval = setInterval( |
| 737 | () => void IndexLock.updateTimestamp(), |
| 738 | 5_000, |
| 739 | ); |
| 740 | |
| 741 | try { |
| 742 | for await (const update of this.refreshDirs( |
| 743 | paths, |
| 744 | localController.signal, |
| 745 | )) { |
| 746 | this.updateProgress(update); |
| 747 | |
| 748 | if (update.status === "failed") { |
| 749 | await this.sendIndexingErrorTelemetry(update); |
| 750 | } |
| 751 | } |
| 752 | } catch (e: any) { |
| 753 | console.log(`Failed refreshing codebase index directories: ${e}`); |
| 754 | await this.handleIndexingError(e); |
| 755 | } |
| 756 | |
| 757 | clearInterval(indexLockTimestampUpdateInterval); // interval will also be cleared when window closes before indexing is finished |
| 758 | await IndexLock.unlock(); |
| 759 | |
| 760 | // Directly refresh submenu items |
| 761 | if (this.messenger) { |
| 762 | this.messenger.send("refreshSubmenuItems", { |
| 763 | providers: "all", |
| 764 | }); |
| 765 | } |
| 766 | if (this.indexingCancellationController === localController) { |
| 767 | this.indexingCancellationController.abort(); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | public async refreshCodebaseIndexFiles(files: string[]) { |
| 772 | // Can be cancelled by codebase index but not vice versa |
no test coverage detected