From f3a252b5dc21acf0c9911fb5bd2ebe555fc5d2de Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 28 Feb 2024 10:55:25 +0100 Subject: [PATCH] Reindex tweaks --- plugs/index/command.ts | 11 ++++++----- web/client.ts | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/plugs/index/command.ts b/plugs/index/command.ts index d7c9f576..61568e5e 100644 --- a/plugs/index/command.ts +++ b/plugs/index/command.ts @@ -10,15 +10,16 @@ export async function reindexCommand() { await editor.flashNotification("Done with page index!"); } -export async function reindexSpace() { +export async function reindexSpace(noClear = false) { if (await system.getMode() === "ro") { console.info("Not reindexing because we're in read-only mode"); return; } - console.log("Clearing page index..."); - // Executed this way to not have to embed the search plug code here - await system.invokeFunction("index.clearIndex"); - + if (!noClear) { + console.log("Clearing page index..."); + // Executed this way to not have to embed the search plug code here + await system.invokeFunction("index.clearIndex"); + } // Load builtins await system.invokeFunction("index.loadBuiltinsIntoIndex"); diff --git a/web/client.ts b/web/client.ts index 4e4776e6..f2d647a4 100644 --- a/web/client.ts +++ b/web/client.ts @@ -274,10 +274,14 @@ export class Client { console.error, ); } else { - // This was the initial sync, let's mark a full index as completed - await markFullSpaceIndexComplete(this.stateDataStore); - // And load space scripts, which probably weren't loaded before + // Let's load space scripts, which probably weren't loaded before await this.clientSystem.loadSpaceScripts(); + console.log( + "Initial sync completed, now need to do a full space index to ensure all pages are indexed using any custom space script indexers", + ); + ensureSpaceIndex(this.stateDataStore, this.clientSystem.system).catch( + console.error, + ); } } if (operations) {