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