From 51a9cc7d9052f320480886f84c09d760c1d90aea Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Thu, 19 Oct 2023 21:09:29 +0200 Subject: [PATCH] Slight indexing perf improvement --- src/cache-manager.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cache-manager.ts b/src/cache-manager.ts index ec94b2e..3503b23 100644 --- a/src/cache-manager.ts +++ b/src/cache-manager.ts @@ -1,4 +1,4 @@ -import { Notice } from 'obsidian' +import { Notice, TFile } from 'obsidian' import { type DocumentRef, getTextExtractor, @@ -32,8 +32,9 @@ import { settings } from './settings' async function getAndMapIndexedDocument( path: string ): Promise { - const file = app.vault.getFiles().find(f => f.path === path) + const file = app.vault.getAbstractFileByPath(path) if (!file) throw new Error(`Invalid file path: "${path}"`) + if (!(file instanceof TFile)) throw new Error(`Not a TFile: "${path}"`) let content: string | null = null const extractor = getTextExtractor()