mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 21:25:45 +08:00
feat: refresh index if version changed (#14150)
This commit is contained in:
@@ -106,10 +106,6 @@ export interface IndexerSync {
|
||||
}
|
||||
|
||||
export class IndexerSyncImpl implements IndexerSync {
|
||||
/**
|
||||
* increase this number to re-index all docs
|
||||
*/
|
||||
readonly INDEXER_VERSION = 2;
|
||||
private abort: AbortController | null = null;
|
||||
private readonly rootDocId = this.doc.spaceId;
|
||||
private readonly status = new IndexerSyncStatus(this.rootDocId);
|
||||
@@ -266,7 +262,8 @@ export class IndexerSyncImpl implements IndexerSync {
|
||||
this.status.errorMessage = null;
|
||||
this.status.statusUpdatedSubject$.next(true);
|
||||
|
||||
console.log('indexer sync start');
|
||||
const indexVersion = await this.indexer.indexVersion();
|
||||
console.log('indexer sync start, version: ', indexVersion);
|
||||
|
||||
const unsubscribe = this.doc.subscribeDocUpdate(update => {
|
||||
if (!this.status.rootDocReady) {
|
||||
@@ -402,7 +399,7 @@ export class IndexerSyncImpl implements IndexerSync {
|
||||
docIndexedClock &&
|
||||
docIndexedClock.timestamp.getTime() ===
|
||||
docClock.timestamp.getTime() &&
|
||||
docIndexedClock.indexerVersion === this.INDEXER_VERSION
|
||||
docIndexedClock.indexerVersion === indexVersion
|
||||
) {
|
||||
// doc is already indexed, just skip
|
||||
continue;
|
||||
@@ -468,7 +465,7 @@ export class IndexerSyncImpl implements IndexerSync {
|
||||
await this.indexerSync.setDocIndexedClock({
|
||||
docId,
|
||||
timestamp: docClock.timestamp,
|
||||
indexerVersion: this.INDEXER_VERSION,
|
||||
indexerVersion: indexVersion,
|
||||
});
|
||||
// #endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user