Tags redo (#624)

Introduction of `tag` and `itags`
This commit is contained in:
Zef Hemel
2024-01-11 13:20:50 +01:00
committed by GitHub
parent 9a07c4c90a
commit 848211120c
31 changed files with 286 additions and 170 deletions
+30
View File
@@ -0,0 +1,30 @@
import { DataStore } from "../plugos/lib/datastore.ts";
import { System } from "../plugos/system.ts";
const indexVersionKey = ["$indexVersion"];
// Bump this one every time a full reinxex is needed
const desiredIndexVersion = 2;
let indexOngoing = false;
export async function ensureSpaceIndex(ds: DataStore, system: System<any>) {
const currentIndexVersion = await ds.get(indexVersionKey);
console.info("Current space index version", currentIndexVersion);
if (currentIndexVersion !== desiredIndexVersion && !indexOngoing) {
console.info("Performing a full space reindex, this could take a while...");
indexOngoing = true;
await system.loadedPlugs.get("index")!.invoke("reindexSpace", []);
console.info("Full space index complete.");
await markFullSpaceIndexComplete(ds);
indexOngoing = false;
} else {
console.info("Space index is up to date");
}
}
export async function markFullSpaceIndexComplete(ds: DataStore) {
await ds.set(indexVersionKey, desiredIndexVersion);
}