Slight indexing perf improvement
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Notice } from 'obsidian'
|
import { Notice, TFile } from 'obsidian'
|
||||||
import {
|
import {
|
||||||
type DocumentRef,
|
type DocumentRef,
|
||||||
getTextExtractor,
|
getTextExtractor,
|
||||||
@@ -32,8 +32,9 @@ import { settings } from './settings'
|
|||||||
async function getAndMapIndexedDocument(
|
async function getAndMapIndexedDocument(
|
||||||
path: string
|
path: string
|
||||||
): Promise<IndexedDocument> {
|
): Promise<IndexedDocument> {
|
||||||
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) throw new Error(`Invalid file path: "${path}"`)
|
||||||
|
if (!(file instanceof TFile)) throw new Error(`Not a TFile: "${path}"`)
|
||||||
let content: string | null = null
|
let content: string | null = null
|
||||||
|
|
||||||
const extractor = getTextExtractor()
|
const extractor = getTextExtractor()
|
||||||
|
|||||||
Reference in New Issue
Block a user