2024-08-07 02:11:38 +08:00
|
|
|
import { space, system } from "@silverbulletmd/silverbullet/syscalls";
|
|
|
|
import type { AttachmentMeta } from "@silverbulletmd/silverbullet/types";
|
2024-05-28 02:33:41 +08:00
|
|
|
import { indexObjects } from "./api.ts";
|
|
|
|
|
2024-07-23 19:12:02 +08:00
|
|
|
// Note: clearFileIndex is not called but since this is the only attachmet:index listener, this should be fine (famous last words)
|
2024-05-31 01:55:35 +08:00
|
|
|
export async function indexAttachment(name: string) {
|
|
|
|
if (await system.getMode() === "ro") {
|
|
|
|
return;
|
2024-05-28 02:33:41 +08:00
|
|
|
}
|
2024-06-13 18:01:40 +08:00
|
|
|
console.log("Indexing attachment", name);
|
2024-05-31 01:55:35 +08:00
|
|
|
const fileMeta = await space.getAttachmentMeta(name);
|
|
|
|
await indexObjects<AttachmentMeta>(fileMeta.name, [fileMeta]);
|
2024-05-28 02:33:41 +08:00
|
|
|
}
|