Ensure reindex with space function indexers

pull/774/head
Zef Hemel 2024-02-28 10:54:31 +01:00
parent 16d1d3265b
commit 0940eb1d15
3 changed files with 13 additions and 3 deletions

View File

@ -64,7 +64,7 @@ export async function plugRunCommand(
export async function runPlug( export async function runPlug(
spacePath: string, spacePath: string,
functionName: string | undefined, functionName: string | undefined,
args: string[] = [], args: any[] = [],
builtinAssetBundle: AssetBundle, builtinAssetBundle: AssetBundle,
kvPrimitives: KvPrimitives, kvPrimitives: KvPrimitives,
httpServerPort?: number, httpServerPort?: number,

View File

@ -100,7 +100,7 @@ export async function serveCommand(
const plugAssets = new AssetBundle(plugAssetBundle as AssetJson); const plugAssets = new AssetBundle(plugAssetBundle as AssetJson);
if (readOnly) { if (readOnly) {
console.log("Indexing the space first. Hang on..."); console.log("Performing initial space indexing...");
await runPlug( await runPlug(
folder, folder,
"index.reindexSpace", "index.reindexSpace",
@ -108,6 +108,16 @@ export async function serveCommand(
plugAssets, plugAssets,
new PrefixedKvPrimitives(baseKvPrimitives, ["*"]), new PrefixedKvPrimitives(baseKvPrimitives, ["*"]),
); );
console.log(
"Now indexing again to make sure any additional space script indexers are run...",
);
await runPlug(
folder,
"index.reindexSpace",
[true], // noClear
plugAssets,
new PrefixedKvPrimitives(baseKvPrimitives, ["*"]),
);
} }
const httpServer = new HttpServer({ const httpServer = new HttpServer({
hostname, hostname,

View File

@ -16,7 +16,7 @@ export async function ensureSpaceIndex(ds: DataStore, system: System<any>) {
if (currentIndexVersion !== desiredIndexVersion && !indexOngoing) { if (currentIndexVersion !== desiredIndexVersion && !indexOngoing) {
console.info("Performing a full space reindex, this could take a while..."); console.info("Performing a full space reindex, this could take a while...");
indexOngoing = true; indexOngoing = true;
await system.invokeFunction("index.reindexSpace", []); await system.invokeFunction("index.reindexSpace", [true]); // noClean = true
console.info("Full space index complete."); console.info("Full space index complete.");
await markFullSpaceIndexComplete(ds); await markFullSpaceIndexComplete(ds);
indexOngoing = false; indexOngoing = false;