fix: do not delete docs indexes on resync

This commit is contained in:
Josh Holmer 2025-06-16 11:35:42 -04:00
parent 869ecec710
commit 0b929bf799
No known key found for this signature in database
GPG key ID: AC90D4A8285601D1

View file

@ -981,17 +981,11 @@ export default class DocsService {
// Otherwise sync the index based on config changes
const oldConfigDocs = oldConfig?.docs || [];
const newConfigDocs = newConfig.docs || [];
const newConfigStartUrls = newConfigDocs.map((doc) => doc.startUrl);
// NOTE since listMetadata filters by embeddings provider id embedding model changes are accounted for here
const currentlyIndexedDocs = await this.listMetadata();
const currentStartUrls = currentlyIndexedDocs.map((doc) => doc.startUrl);
// Anything found in sqlite but not in new config should be deleted
const deletedDocs = currentlyIndexedDocs.filter(
(doc) => !newConfigStartUrls.includes(doc.startUrl),
);
// Anything found in old config, new config, AND sqlite that doesn't match should be reindexed
// TODO if only favicon and title change, only update, don't embed
// Otherwise anything found in new config that isn't in sqlite should be added/indexed
@ -1038,10 +1032,6 @@ export default class DocsService {
...changedDocs.map((doc) => this.indexAndAdd(doc, true)),
...addedDocs.map((doc) => this.indexAndAdd(doc)),
]);
for (const doc of deletedDocs) {
await this.deleteIndexes(doc.startUrl);
}
} catch (e) {
console.error("Error syncing docs index on config update", e);
} finally {