Attempt to fix issue where pages would randomly disappear from the index
I suspect this is due to event triggering order (where clearing happened at the same time as adding new entries), this should fix that.pull/972/head
parent
121ecb328a
commit
d1a827aa4a
|
@ -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;
|
||||
|
|
|
@ -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", {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue