Squashed commit of the following:
commit 739f9c349031510e8ef010ba2445a2a1fdbec247 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 16 16:57:03 2022 +0200 Code cleaning + README commit 85762bae592f3eafd34ba22b0cf1841bfbd91ca6 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 16 14:59:01 2022 +0200 Cleaning deleted PDFs from cache commit 1a37bf38d3f64870d4b40df1b67d8106c893ab64 Author: Simon Cambier <simon.cambier@protonmail.com> Date: Sun Oct 16 13:18:06 2022 +0200 PDF cache saved to IndexedDB
This commit is contained in:
26
src/main.ts
26
src/main.ts
@@ -9,7 +9,6 @@ import { loadSearchHistory } from './search-history'
|
||||
import { isFilePlaintext } from './utils'
|
||||
import * as NotesIndex from './notes-index'
|
||||
import { cacheManager } from './cache-manager'
|
||||
import { pdfManager } from './pdf-manager'
|
||||
|
||||
function _registerAPI(plugin: OmnisearchPlugin): void {
|
||||
registerAPI('omnisearch', api, plugin as any)
|
||||
@@ -25,7 +24,6 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
await loadSettings(this)
|
||||
await loadSearchHistory()
|
||||
await cacheManager.loadNotesCache()
|
||||
await pdfManager.loadPDFCache()
|
||||
|
||||
_registerAPI(this)
|
||||
|
||||
@@ -91,7 +89,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
|
||||
onunload(): void {
|
||||
console.log('Omnisearch - Interrupting PDF indexing')
|
||||
NotesIndex.pdfQueue.pause()
|
||||
NotesIndex.pdfQueue.clearQueue()
|
||||
}
|
||||
|
||||
addRibbonButton(): void {
|
||||
@@ -102,17 +100,17 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
}
|
||||
|
||||
async function cleanOldCacheFiles() {
|
||||
const oldSearchIndexFilePath = `${app.vault.configDir}/plugins/omnisearch/searchIndex.json`
|
||||
if (await app.vault.adapter.exists(oldSearchIndexFilePath)) {
|
||||
try {
|
||||
await app.vault.adapter.remove(oldSearchIndexFilePath)
|
||||
} catch (e) {}
|
||||
}
|
||||
const oldNnotesCacheFilePath = `${app.vault.configDir}/plugins/omnisearch/notesCache.json`
|
||||
if (await app.vault.adapter.exists(oldNnotesCacheFilePath)) {
|
||||
try {
|
||||
await app.vault.adapter.remove(oldNnotesCacheFilePath)
|
||||
} catch (e) {}
|
||||
const toDelete = [
|
||||
`${app.vault.configDir}/plugins/omnisearch/searchIndex.json`,
|
||||
`${app.vault.configDir}/plugins/omnisearch/notesCache.json`,
|
||||
`${app.vault.configDir}/plugins/omnisearch/pdfCache.data`
|
||||
]
|
||||
for (const item of toDelete) {
|
||||
if (await app.vault.adapter.exists(item)) {
|
||||
try {
|
||||
await app.vault.adapter.remove(item)
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user