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 { AttachmentMeta } from "$sb/types.ts";
|
||||||
import { indexObjects } from "./api.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) {
|
export async function indexAttachment(name: string) {
|
||||||
if (await system.getMode() === "ro") {
|
if (await system.getMode() === "ro") {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { isTemplate } from "$lib/cheap_yaml.ts";
|
||||||
import { sleep } from "$lib/async.ts";
|
import { sleep } from "$lib/async.ts";
|
||||||
import { plugPrefix } from "$common/spaces/constants.ts";
|
import { plugPrefix } from "$common/spaces/constants.ts";
|
||||||
import { indexAttachment } from "./attachment.ts";
|
import { indexAttachment } from "./attachment.ts";
|
||||||
|
import { clearFileIndex } from "./api.ts";
|
||||||
|
|
||||||
export async function reindexCommand() {
|
export async function reindexCommand() {
|
||||||
await editor.flashNotification("Performing full page reindex...");
|
await editor.flashNotification("Performing full page reindex...");
|
||||||
|
@ -75,6 +76,9 @@ export async function parseIndexTextRepublish({ name, text }: IndexEvent) {
|
||||||
}
|
}
|
||||||
const parsed = await markdown.parseMarkdown(text);
|
const parsed = await markdown.parseMarkdown(text);
|
||||||
|
|
||||||
|
// First clear the old file index entries
|
||||||
|
await clearFileIndex(name);
|
||||||
|
|
||||||
if (isTemplate(text)) {
|
if (isTemplate(text)) {
|
||||||
// console.log("Indexing", name, "as template");
|
// console.log("Indexing", name, "as template");
|
||||||
await events.dispatchEvent("page:indexTemplate", {
|
await events.dispatchEvent("page:indexTemplate", {
|
||||||
|
|
|
@ -39,7 +39,6 @@ functions:
|
||||||
env: server
|
env: server
|
||||||
events:
|
events:
|
||||||
- file:deleted
|
- file:deleted
|
||||||
- file:changed
|
|
||||||
|
|
||||||
parseIndexTextRepublish:
|
parseIndexTextRepublish:
|
||||||
path: "./command.ts:parseIndexTextRepublish"
|
path: "./command.ts:parseIndexTextRepublish"
|
||||||
|
@ -52,6 +51,7 @@ functions:
|
||||||
command:
|
command:
|
||||||
name: "Space: Reindex"
|
name: "Space: Reindex"
|
||||||
requireMode: rw
|
requireMode: rw
|
||||||
|
|
||||||
processIndexQueue:
|
processIndexQueue:
|
||||||
path: ./command.ts:processIndexQueue
|
path: ./command.ts:processIndexQueue
|
||||||
mqSubscriptions:
|
mqSubscriptions:
|
||||||
|
|
Loading…
Reference in New Issue