Reindex tweaks

pull/774/head
Zef Hemel 2024-02-28 10:55:25 +01:00
parent 59ab0cbaff
commit f3a252b5dc
2 changed files with 13 additions and 8 deletions

View File

@ -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");

View File

@ -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) {