Faster startup indexing

This commit is contained in:
Simon Cambier
2022-10-02 22:04:27 +02:00
parent 9bba8ae5fb
commit a4920c223e

View File

@@ -100,14 +100,16 @@ export async function initGlobalSearchIndex(): Promise<void> {
// This is basically the same behavior as MiniSearch's `addAllAsync()`.
// We index markdown and plaintext files by batches of 10
const promises: Promise<void>[] = []
for (let i = 0; i < files.length; ++i) {
if (i % 10 === 0) await wait(0)
const file = files[i]
if (getNoteFromCache(file.path)) {
removeFromIndex(file.path)
}
await addToIndex(file)
promises.push(addToIndex(file))
}
await Promise.all(promises)
if (files.length > 0) {
const message = `Omnisearch - Indexed ${files.length} ${notesSuffix} in ${