Removed unused processQueue

This commit is contained in:
Simon Cambier
2022-11-06 12:44:19 +01:00
parent 38607837e8
commit 40f9df6a47
7 changed files with 4 additions and 27 deletions

View File

@@ -45,7 +45,6 @@
"lodash-es": "4.17.21", "lodash-es": "4.17.21",
"minisearch": "github:scambier/minisearch#callback_desync", "minisearch": "github:scambier/minisearch#callback_desync",
"obsidian-text-extract": "1.0.1", "obsidian-text-extract": "1.0.1",
"p-limit": "^4.0.0",
"pure-md5": "^0.1.14" "pure-md5": "^0.1.14"
}, },
"pnpm": { "pnpm": {

2
pnpm-lock.yaml generated
View File

@@ -24,7 +24,6 @@ specifiers:
minisearch: github:scambier/minisearch#callback_desync minisearch: github:scambier/minisearch#callback_desync
obsidian: latest obsidian: latest
obsidian-text-extract: 1.0.1 obsidian-text-extract: 1.0.1
p-limit: ^4.0.0
prettier: ^2.7.1 prettier: ^2.7.1
prettier-plugin-svelte: ^2.8.0 prettier-plugin-svelte: ^2.8.0
pure-md5: ^0.1.14 pure-md5: ^0.1.14
@@ -42,7 +41,6 @@ dependencies:
lodash-es: 4.17.21 lodash-es: 4.17.21
minisearch: github.com/scambier/minisearch/adf11cab46d851220a41c9ad95ed986b630f0f3c minisearch: github.com/scambier/minisearch/adf11cab46d851220a41c9ad95ed986b630f0f3c
obsidian-text-extract: 1.0.1 obsidian-text-extract: 1.0.1
p-limit: 4.0.0
pure-md5: 0.1.14 pure-md5: 0.1.14
devDependencies: devDependencies:

View File

@@ -4,8 +4,7 @@ import type { IndexedDocument } from './globals'
export class OmnisearchCache extends Dexie { export class OmnisearchCache extends Dexie {
public static readonly dbVersion = 7 public static readonly dbVersion = 7
public static readonly dbPrefix = 'omnisearch/cache/' public static readonly dbName = 'omnisearch/cache/' + app.appId
public static readonly dbName = OmnisearchCache.dbPrefix + app.appId
private static instance: OmnisearchCache private static instance: OmnisearchCache
@@ -15,7 +14,7 @@ export class OmnisearchCache extends Dexie {
public static async clearOldDatabases(): Promise<void> { public static async clearOldDatabases(): Promise<void> {
const toDelete = (await indexedDB.databases()).filter( const toDelete = (await indexedDB.databases()).filter(
db => db =>
db.name?.startsWith(OmnisearchCache.dbPrefix) && db.name === OmnisearchCache.dbName &&
// version multiplied by 10 https://github.com/dexie/Dexie.js/issues/59 // version multiplied by 10 https://github.com/dexie/Dexie.js/issues/59
db.version !== OmnisearchCache.dbVersion * 10 db.version !== OmnisearchCache.dbVersion * 10
) )

View File

@@ -10,8 +10,7 @@ import * as NotesIndex from './notes-index'
import type { TFile } from 'obsidian' import type { TFile } from 'obsidian'
import type { IndexedDocument } from './globals' import type { IndexedDocument } from './globals'
import { getNonExistingNotes } from './tools/notes' import { getNonExistingNotes } from './tools/notes'
import { database } from './database' import { getPdfText } from 'obsidian-text-extract'
import { getImageText, getPdfText } from 'obsidian-text-extract'
/** /**
* Return all plaintext files as IndexedDocuments * Return all plaintext files as IndexedDocuments

View File

@@ -85,7 +85,7 @@ export default class OmnisearchPlugin extends Plugin {
} }
onunload(): void { onunload(): void {
NotesIndex.processQueue.clearQueue()
} }
addRibbonButton(): void { addRibbonButton(): void {

View File

@@ -4,15 +4,9 @@ import { removeAnchors } from './tools/notes'
import { settings } from './settings' import { settings } from './settings'
import { SearchEngine } from './search/search-engine' import { SearchEngine } from './search/search-engine'
import { cacheManager } from './cache-manager' import { cacheManager } from './cache-manager'
import pLimit from 'p-limit'
import type { IndexedDocument } from './globals' import type { IndexedDocument } from './globals'
import { fileToIndexedDocument } from './file-loader' import { fileToIndexedDocument } from './file-loader'
/**
* Use this processing queue to handle all heavy work
*/
export const processQueue = pLimit(settings.backgroundProcesses)
/** /**
* Adds a file to the search index * Adds a file to the search index
* @param file * @param file

View File

@@ -1,6 +1,5 @@
import { import {
Notice, Notice,
Platform,
Plugin, Plugin,
PluginSettingTab, PluginSettingTab,
Setting, Setting,
@@ -26,8 +25,6 @@ export interface OmnisearchSettings extends WeightingSettings {
indexedFileTypes: string[] indexedFileTypes: string[]
/** Enable PDF indexing */ /** Enable PDF indexing */
PDFIndexing: boolean PDFIndexing: boolean
/** Max number of spawned processes for background tasks, such as extracting text from PDFs */
backgroundProcesses: number
/** Display Omnisearch popup notices over Obsidian */ /** Display Omnisearch popup notices over Obsidian */
showIndexingNotices: boolean showIndexingNotices: boolean
/** Activate the small 🔍 button on Obsidian's ribbon */ /** Activate the small 🔍 button on Obsidian's ribbon */
@@ -313,20 +310,11 @@ export class SettingsTab extends PluginSettingTab {
} }
} }
// Determining the maximum concurrent processes/workers/promises for heavy work,
// without hogging all the resources.
const cpuCount = Platform.isMobileApp ? 1 : require('os').cpus().length
let backgroundProcesses = Math.max(1, Math.floor(cpuCount * 0.75))
if (backgroundProcesses == cpuCount) {
backgroundProcesses = 1
}
export const DEFAULT_SETTINGS: OmnisearchSettings = { export const DEFAULT_SETTINGS: OmnisearchSettings = {
respectExcluded: true, respectExcluded: true,
ignoreDiacritics: true, ignoreDiacritics: true,
indexedFileTypes: [] as string[], indexedFileTypes: [] as string[],
PDFIndexing: false, PDFIndexing: false,
backgroundProcesses,
showIndexingNotices: false, showIndexingNotices: false,
showShortName: false, showShortName: false,