Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): indexer data loss (#9216)

EYHNf8e7abd01854
diff --git a/packages/common/infra/src/sync/indexer/impl/indexeddb/data-struct.ts b/packages/common/infra/src/sync/indexer/impl/indexeddb/data-struct.ts
index 14bda288cf..e0637056e8 100644
--- a/packages/common/infra/src/sync/indexer/impl/indexeddb/data-struct.ts
+++ b/packages/common/infra/src/sync/indexer/impl/indexeddb/data-struct.ts
@@ -143,12 +143,15 @@ export class DataStruct {
if (nid) {
await trx.objectStore('records').delete(nid);
+ } else {
+ return;
}
const indexIds = await trx
.objectStore('invertedIndex')
.index('nid')
.getAllKeys(nid);
+
for (const indexId of indexIds) {
await trx.objectStore('invertedIndex').delete(indexId);
}
@@ -266,6 +269,8 @@ export class DataStruct {
nodes.push(this.resultNode(record, options, match, nid));
}
+ console.log(nodes);
+
return {
pagination: {
count: match.size(),
diff --git a/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts b/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts
index 392613cd12..419b8a5043 100644
--- a/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts
+++ b/packages/frontend/core/src/modules/docs-search/entities/docs-indexer.ts
@@ -36,7 +36,7 @@ export class DocsIndexer extends Entity {
/**
* increase this number to re-index all docs
*/
- static INDEXER_VERSION = 11;
+ static INDEXER_VERSION = 17;
private readonly jobQueue: JobQueue<IndexerJobPayload> =
new IndexedDBJobQueue<IndexerJobPayload>(