#254 - Index unsupported files

This commit is contained in:
Simon Cambier
2023-07-17 11:49:54 +02:00
parent 6da4a3e785
commit 1a109d6d89
4 changed files with 62 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ import {
SPACE_OR_PUNCTUATION,
type SearchMatch,
} from '../globals'
import { settings } from '../settings'
import { canIndexUnsupportedFiles, settings } from '../settings'
import { type BinaryLike, createHash } from 'crypto'
import { md5 } from 'pure-md5'
@@ -26,7 +26,7 @@ export function highlighter(str: string): string {
return `<span class="${highlightClass}">${str}</span>`
}
export function highlighterGroups(substring: string, ...args: any[]) {
export function highlighterGroups(_substring: string, ...args: any[]) {
// args[0] is the single char preceding args[1], which is the word we want to highlight
if (!!args[1].trim())
return `<span>${args[0]}</span><span class="${highlightClass}">${args[1]}</span>`
@@ -263,7 +263,7 @@ export function getCtrlKeyLabel(): 'ctrl' | '⌘' {
return Platform.isMacOS ? '⌘' : 'ctrl'
}
export function isFileIndexable(path: string): boolean {
export function isContentIndexable(path: string): boolean {
const hasTextExtractor = !!getTextExtractor()
const canIndexPDF = hasTextExtractor && settings.PDFIndexing
const canIndexImages = hasTextExtractor && settings.imagesIndexing
@@ -276,6 +276,21 @@ export function isFileIndexable(path: string): boolean {
)
}
export function isFilenameIndexable(path: string): boolean {
return (
canIndexUnsupportedFiles() ||
isFilePlaintext(path) ||
isFileCanvas(path) ||
isFileFromDataloomPlugin(path) ||
isFilePDF(path) ||
isFileImage(path)
)
}
export function isFileIndexable(path: string): boolean {
return isFilenameIndexable(path) || isContentIndexable(path)
}
export function isFileImage(path: string): boolean {
const ext = getExtension(path)
return ext === 'png' || ext === 'jpg' || ext === 'jpeg' || ext === 'webp'