MCPcopy
hub / github.com/continuedev/continue / syncDocs

Method syncDocs

core/indexing/docs/DocsService.ts:927–1020  ·  view source on GitHub ↗

* Sync with no embeddings provider change

(
    oldConfig: ContinueConfig | undefined,
    newConfig: ContinueConfig,
    forceReindex: boolean,
  )

Source from the content-addressed store, hash-verified

925 * Sync with no embeddings provider change
926 */
927 private async syncDocs(
928 oldConfig: ContinueConfig | undefined,
929 newConfig: ContinueConfig,
930 forceReindex: boolean,
931 ) {
932 try {
933 this.isSyncing = true;
934
935 // Otherwise sync the index based on config changes
936 const oldConfigDocs = oldConfig?.docs || [];
937 const newConfigDocs = newConfig.docs || [];
938
939 // NOTE since listMetadata filters by embeddings provider id embedding model changes are accounted for here
940 const currentlyIndexedDocs = await this.listMetadata();
941 const currentStartUrls = currentlyIndexedDocs.map((doc) => doc.startUrl);
942
943 // Anything found in old config, new config, AND sqlite that doesn't match should be reindexed
944 // Anything found in new config that isn't in sqlite should be added/indexed
945 const addedDocs: SiteIndexingConfig[] = [];
946 const changedDocs: SiteIndexingConfig[] = [];
947 for (const doc of newConfigDocs) {
948 const currentIndexedDoc = currentStartUrls.includes(doc.startUrl);
949
950 if (currentIndexedDoc) {
951 const oldConfigDoc = oldConfigDocs.find(
952 (d) => d.startUrl === doc.startUrl,
953 );
954
955 // TODO: Changes to the docs config made while Continue isn't running won't be caught
956 if (
957 oldConfigDoc &&
958 !siteIndexingConfigsAreEqual(
959 oldConfigDoc,
960 doc,
961 oldConfig,
962 newConfig,
963 )
964 ) {
965 // When only the title or faviconUrl changed, Update the sqlite metadate instead of reindexing
966 if (
967 siteIndexingConfigsAreEqualExceptTitleAndFavicon(
968 oldConfigDoc,
969 doc,
970 oldConfig,
971 newConfig,
972 )
973 ) {
974 await this.updateMetadataInSqlite(doc);
975 } else {
976 changedDocs.push(doc);
977 }
978 } else {
979 if (forceReindex) {
980 changedDocs.push(doc);
981 } else {
982 // This is a temperary fix to catch the changes to the docs config that were made when Continue isn't running
983 // We only update title and faviconUrl here
984 await this.updateMetadataInSqlite(doc);

Callers 2

handleConfigUpdateMethod · 0.95
syncDocsWithPromptMethod · 0.95

Calls 9

listMetadataMethod · 0.95
handleStatusUpdateMethod · 0.95
indexAndAddMethod · 0.95
errorMethod · 0.80
pushMethod · 0.65
sendMethod · 0.65

Tested by

no test coverage detected