diff --git a/package.json b/package.json index fc12206..feabbf3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "lodash-es": "4.17.21", "minisearch": "github:scambier/minisearch#callback_desync", "obsidian-text-extract": "1.0.1", - "p-limit": "^4.0.0", "pure-md5": "^0.1.14" }, "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38ac530..3775cc6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,6 @@ specifiers: minisearch: github:scambier/minisearch#callback_desync obsidian: latest obsidian-text-extract: 1.0.1 - p-limit: ^4.0.0 prettier: ^2.7.1 prettier-plugin-svelte: ^2.8.0 pure-md5: ^0.1.14 @@ -42,7 +41,6 @@ dependencies: lodash-es: 4.17.21 minisearch: github.com/scambier/minisearch/adf11cab46d851220a41c9ad95ed986b630f0f3c obsidian-text-extract: 1.0.1 - p-limit: 4.0.0 pure-md5: 0.1.14 devDependencies: diff --git a/src/database.ts b/src/database.ts index 379f3d0..eb94ea4 100644 --- a/src/database.ts +++ b/src/database.ts @@ -4,8 +4,7 @@ import type { IndexedDocument } from './globals' export class OmnisearchCache extends Dexie { public static readonly dbVersion = 7 - public static readonly dbPrefix = 'omnisearch/cache/' - public static readonly dbName = OmnisearchCache.dbPrefix + app.appId + public static readonly dbName = 'omnisearch/cache/' + app.appId private static instance: OmnisearchCache @@ -15,7 +14,7 @@ export class OmnisearchCache extends Dexie { public static async clearOldDatabases(): Promise { const toDelete = (await indexedDB.databases()).filter( db => - db.name?.startsWith(OmnisearchCache.dbPrefix) && + db.name === OmnisearchCache.dbName && // version multiplied by 10 https://github.com/dexie/Dexie.js/issues/59 db.version !== OmnisearchCache.dbVersion * 10 ) diff --git a/src/file-loader.ts b/src/file-loader.ts index 06714c6..2e44fd4 100644 --- a/src/file-loader.ts +++ b/src/file-loader.ts @@ -10,8 +10,7 @@ import * as NotesIndex from './notes-index' import type { TFile } from 'obsidian' import type { IndexedDocument } from './globals' import { getNonExistingNotes } from './tools/notes' -import { database } from './database' -import { getImageText, getPdfText } from 'obsidian-text-extract' +import { getPdfText } from 'obsidian-text-extract' /** * Return all plaintext files as IndexedDocuments diff --git a/src/main.ts b/src/main.ts index 1e4c423..9891503 100644 --- a/src/main.ts +++ b/src/main.ts @@ -85,7 +85,7 @@ export default class OmnisearchPlugin extends Plugin { } onunload(): void { - NotesIndex.processQueue.clearQueue() + } addRibbonButton(): void { diff --git a/src/notes-index.ts b/src/notes-index.ts index 28586ba..b99a1a1 100644 --- a/src/notes-index.ts +++ b/src/notes-index.ts @@ -4,15 +4,9 @@ import { removeAnchors } from './tools/notes' import { settings } from './settings' import { SearchEngine } from './search/search-engine' import { cacheManager } from './cache-manager' -import pLimit from 'p-limit' import type { IndexedDocument } from './globals' 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 * @param file diff --git a/src/settings.ts b/src/settings.ts index 67619a1..968bcf9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,6 +1,5 @@ import { Notice, - Platform, Plugin, PluginSettingTab, Setting, @@ -26,8 +25,6 @@ export interface OmnisearchSettings extends WeightingSettings { indexedFileTypes: string[] /** Enable PDF indexing */ PDFIndexing: boolean - /** Max number of spawned processes for background tasks, such as extracting text from PDFs */ - backgroundProcesses: number /** Display Omnisearch popup notices over Obsidian */ showIndexingNotices: boolean /** 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 = { respectExcluded: true, ignoreDiacritics: true, indexedFileTypes: [] as string[], PDFIndexing: false, - backgroundProcesses, showIndexingNotices: false, showShortName: false,