Logs & cleaning

This commit is contained in:
Simon Cambier
2022-11-27 16:36:06 +01:00
parent f67d9d1a25
commit e8d0efbd5b
3 changed files with 12 additions and 66 deletions

View File

@@ -10,7 +10,7 @@ import {
import type { TFile } from 'obsidian'
import type { IndexedDocument } from './globals'
import { getImageText, getPdfText } from 'obsidian-text-extract'
import { cacheManager } from "./cache-manager";
import { cacheManager } from './cache-manager'
/**
* Return all plaintext files as IndexedDocuments
@@ -57,61 +57,3 @@ async function getBinaryFiles(files: TFile[]): Promise<IndexedDocument[]> {
await Promise.all(input)
return data
}
/**
* Convert a file into an IndexedDocument.
* Will use the cache if possible.
*/
// async function fileToIndexedDocument(
// file: TFile
// ): Promise<IndexedDocument> {
// let content: string
// if (isFilePlaintext(file.path)) {
// content = await app.vault.cachedRead(file)
// } else if (isFilePDF(file.path)) {
// content = await getPdfText(file)
// } else if (isFileImage(file.path)) {
// content = await getImageText(file)
// } else {
// throw new Error('Invalid file: ' + file.path)
// }
//
// content = removeDiacritics(content)
// const metadata = app.metadataCache.getFileCache(file)
//
// // Look for links that lead to non-existing files,
// // and add them to the index.
// if (metadata) {
// // FIXME: https://github.com/scambier/obsidian-omnisearch/issues/129
// const nonExisting = getNonExistingNotes(file, metadata)
// for (const name of nonExisting.filter(
// o => !cacheManager.getLiveDocument(o)
// )) {
// NotesIndex.addNonExistingToIndex(name, file.path)
// }
//
// // EXCALIDRAW
// // Remove the json code
// if (metadata.frontmatter?.['excalidraw-plugin']) {
// const comments =
// metadata.sections?.filter(s => s.type === 'comment') ?? []
// for (const { start, end } of comments.map(c => c.position)) {
// content =
// content.substring(0, start.offset - 1) + content.substring(end.offset)
// }
// }
// }
//
// return {
// basename: removeDiacritics(file.basename),
// content,
// path: file.path,
// mtime: file.stat.mtime,
//
// tags: getTagsFromMetadata(metadata),
// aliases: getAliasesFromMetadata(metadata).join(''),
// headings1: metadata ? extractHeadingsFromCache(metadata, 1).join(' ') : '',
// headings2: metadata ? extractHeadingsFromCache(metadata, 2).join(' ') : '',
// headings3: metadata ? extractHeadingsFromCache(metadata, 3).join(' ') : '',
// }
// }