Removed file non longer used
This commit is contained in:
@@ -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<IndexedDocument[]> {
|
||||
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<IndexedDocument[]> {
|
||||
const files = app.vault.getFiles().filter(f => isFilePDF(f.path))
|
||||
return await getBinaryFiles(files)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all imageas as IndexedDocuments.
|
||||
*/
|
||||
export async function getImagesAsDocuments(): Promise<IndexedDocument[]> {
|
||||
const files = app.vault.getFiles().filter(f => isFileImage(f.path))
|
||||
return await getBinaryFiles(files)
|
||||
}
|
||||
|
||||
async function getBinaryFiles(files: TFile[]): Promise<IndexedDocument[]> {
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user