Initial index on plug:run
This commit is contained in:
parent
2844c8bc25
commit
e23b0808e0
@ -26,7 +26,7 @@ export async function runPlug(
|
||||
dbPath,
|
||||
app,
|
||||
);
|
||||
await serverSystem.init();
|
||||
await serverSystem.init(true);
|
||||
app.listen({
|
||||
hostname: httpHostname,
|
||||
port: httpServerPort,
|
||||
|
@ -51,7 +51,7 @@ export class ServerSystem {
|
||||
}
|
||||
|
||||
// Always needs to be invoked right after construction
|
||||
async init() {
|
||||
async init(awaitIndex = false) {
|
||||
// Event hook
|
||||
const eventHook = new EventHook();
|
||||
this.system.addHook(eventHook);
|
||||
@ -151,12 +151,15 @@ export class ServerSystem {
|
||||
// Check if this space was ever indexed before
|
||||
if (!await this.ds.get(["$initialIndexDone"])) {
|
||||
console.log("Indexing space for the first time (in the background)");
|
||||
this.system.loadedPlugs.get("index")!.invoke(
|
||||
const indexPromise = this.system.loadedPlugs.get("index")!.invoke(
|
||||
"reindexSpace",
|
||||
[],
|
||||
).then(() => {
|
||||
this.ds.set(["$initialIndexDone"], true);
|
||||
}).catch(console.error);
|
||||
if (awaitIndex) {
|
||||
await indexPromise;
|
||||
}
|
||||
}
|
||||
|
||||
await eventHook.dispatchEvent("system:ready");
|
||||
|
Loading…
Reference in New Issue
Block a user