Removed useless cache writing
This commit is contained in:
@@ -56,7 +56,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
this.app.vault.on('create', async file => {
|
||||
if (isFileIndexable(file.path)) {
|
||||
await cacheManager.addToLiveCache(file.path)
|
||||
searchEngine.addFromPaths([file.path], false)
|
||||
searchEngine.addFromPaths([file.path])
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -80,7 +80,7 @@ export default class OmnisearchPlugin extends Plugin {
|
||||
cacheManager.removeFromLiveCache(oldPath)
|
||||
cacheManager.addToLiveCache(file.path)
|
||||
searchEngine.removeFromPaths([oldPath])
|
||||
await searchEngine.addFromPaths([file.path], false)
|
||||
await searchEngine.addFromPaths([file.path])
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -157,10 +157,7 @@ async function populateIndex(): Promise<void> {
|
||||
|
||||
indexingStep.set(IndexingStepType.IndexingFiles)
|
||||
searchEngine.removeFromPaths(diff.toRemove.map(o => o.path))
|
||||
await searchEngine.addFromPaths(
|
||||
diff.toAdd.map(o => o.path),
|
||||
true
|
||||
)
|
||||
await searchEngine.addFromPaths(diff.toAdd.map(o => o.path))
|
||||
|
||||
if (diff.toRemove.length || diff.toAdd.length) {
|
||||
indexingStep.set(IndexingStepType.WritingCache)
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function refreshIndex(): Promise<void> {
|
||||
const paths = [...notesToReindex].map(n => n.path)
|
||||
if (paths.length) {
|
||||
searchEngine.removeFromPaths(paths)
|
||||
searchEngine.addFromPaths(paths, false)
|
||||
searchEngine.addFromPaths(paths)
|
||||
notesToReindex.clear()
|
||||
// console.log(`Omnisearch - Reindexed ${paths.length} file(s)`)
|
||||
}
|
||||
|
||||
@@ -101,10 +101,7 @@ export class Omnisearch {
|
||||
* Add notes/PDFs/images to the search index
|
||||
* @param paths
|
||||
*/
|
||||
public async addFromPaths(
|
||||
paths: string[],
|
||||
mustWriteToCache: boolean
|
||||
): Promise<void> {
|
||||
public async addFromPaths(paths: string[]): Promise<void> {
|
||||
let documents = await Promise.all(
|
||||
paths.map(async path => await cacheManager.getDocument(path))
|
||||
)
|
||||
@@ -127,10 +124,6 @@ export class Omnisearch {
|
||||
|
||||
// Add docs to minisearch
|
||||
await this.minisearch.addAllAsync(docs)
|
||||
// Save the index
|
||||
if (mustWriteToCache) {
|
||||
await this.writeToCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +298,6 @@ export class Omnisearch {
|
||||
.filter(s => s.value.startsWith('#'))
|
||||
.map(s => s.value)
|
||||
|
||||
// TODO: this already called in search(), pass each document in its SearchResult instead?
|
||||
const documents = await Promise.all(
|
||||
results.map(async result => await cacheManager.getDocument(result.id))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user