diff --git a/plugs/index/attachment.ts b/plugs/index/attachment.ts index e88583c6..ebf53e94 100644 --- a/plugs/index/attachment.ts +++ b/plugs/index/attachment.ts @@ -2,6 +2,7 @@ import { space, system } from "$sb/syscalls.ts"; import { AttachmentMeta } from "$sb/types.ts"; import { indexObjects } from "./api.ts"; +// Note: clearFileIndex is not called but since this is the only attachmet:index listener, this should be fine (famous last words) export async function indexAttachment(name: string) { if (await system.getMode() === "ro") { return; diff --git a/plugs/index/command.ts b/plugs/index/command.ts index 4aac2520..536774d5 100644 --- a/plugs/index/command.ts +++ b/plugs/index/command.ts @@ -4,6 +4,7 @@ import { isTemplate } from "$lib/cheap_yaml.ts"; import { sleep } from "$lib/async.ts"; import { plugPrefix } from "$common/spaces/constants.ts"; import { indexAttachment } from "./attachment.ts"; +import { clearFileIndex } from "./api.ts"; export async function reindexCommand() { await editor.flashNotification("Performing full page reindex..."); @@ -75,6 +76,9 @@ export async function parseIndexTextRepublish({ name, text }: IndexEvent) { } const parsed = await markdown.parseMarkdown(text); + // First clear the old file index entries + await clearFileIndex(name); + if (isTemplate(text)) { // console.log("Indexing", name, "as template"); await events.dispatchEvent("page:indexTemplate", { diff --git a/plugs/index/index.plug.yaml b/plugs/index/index.plug.yaml index d827df32..18532d42 100644 --- a/plugs/index/index.plug.yaml +++ b/plugs/index/index.plug.yaml @@ -39,7 +39,6 @@ functions: env: server events: - file:deleted - - file:changed parseIndexTextRepublish: path: "./command.ts:parseIndexTextRepublish" @@ -52,6 +51,7 @@ functions: command: name: "Space: Reindex" requireMode: rw + processIndexQueue: path: ./command.ts:processIndexQueue mqSubscriptions: