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()