From 46fb100f3549f24110d9f8a6244d6f54dfcf0924 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sun, 16 Jul 2023 22:06:00 +0200 Subject: [PATCH] Removed file non longer used --- src/file-loader.ts | 50 ---------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/file-loader.ts diff --git a/src/file-loader.ts b/src/file-loader.ts deleted file mode 100644 index 503735f..0000000 --- a/src/file-loader.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { isFileImage, isFilePDF, isFilePlaintext } from './tools/utils' -import type { TFile } from 'obsidian' -import type { IndexedDocument } from './globals' -import { cacheManager } from './cache-manager' - -/** - * Return all plaintext files as IndexedDocuments - */ -export async function getPlainTextFiles(): Promise { - const allFiles = app.vault.getFiles().filter(f => isFilePlaintext(f.path)) - const data: IndexedDocument[] = [] - for (const file of allFiles) { - const doc = await cacheManager.getDocument(file.path) - data.push(doc) - // await cacheManager.updateLiveDocument(file.path, doc) - } - return data -} - -/** - * Return all PDFs as IndexedDocuments. - */ -export async function getPDFAsDocuments(): Promise { - const files = app.vault.getFiles().filter(f => isFilePDF(f.path)) - return await getBinaryFiles(files) -} - -/** - * Return all imageas as IndexedDocuments. - */ -export async function getImagesAsDocuments(): Promise { - const files = app.vault.getFiles().filter(f => isFileImage(f.path)) - return await getBinaryFiles(files) -} - -async function getBinaryFiles(files: TFile[]): Promise { - const data: IndexedDocument[] = [] - const input = [] - for (const file of files) { - input.push( - new Promise(async (resolve, _reject) => { - const doc = await cacheManager.getDocument(file.path) - data.push(doc) - return resolve(null) - }) - ) - } - await Promise.all(input) - return data -}