Fixed indexingStep messages
This commit is contained in:
@@ -123,6 +123,7 @@ async function populateIndex(): Promise<void> {
|
|||||||
|
|
||||||
if (!Platform.isIosApp) {
|
if (!Platform.isIosApp) {
|
||||||
console.time('Omnisearch - Loading index from cache')
|
console.time('Omnisearch - Loading index from cache')
|
||||||
|
indexingStep.set(IndexingStepType.LoadingCache)
|
||||||
await searchEngine.loadCache()
|
await searchEngine.loadCache()
|
||||||
console.timeEnd('Omnisearch - Loading index from cache')
|
console.timeEnd('Omnisearch - Loading index from cache')
|
||||||
}
|
}
|
||||||
@@ -157,6 +158,7 @@ async function populateIndex(): Promise<void> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (diff.toRemove.length || diff.toAdd.length) {
|
if (diff.toRemove.length || diff.toAdd.length) {
|
||||||
|
indexingStep.set(IndexingStepType.WritingCache)
|
||||||
await searchEngine.writeToCache()
|
await searchEngine.writeToCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export class Omnisearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadCache(): Promise<void> {
|
async loadCache(): Promise<void> {
|
||||||
indexingStep.set(IndexingStepType.LoadingCache)
|
|
||||||
const cache = await cacheManager.getMinisearchCache()
|
const cache = await cacheManager.getMinisearchCache()
|
||||||
if (cache) {
|
if (cache) {
|
||||||
this.minisearch = MiniSearch.loadJS(cache.data, Omnisearch.options)
|
this.minisearch = MiniSearch.loadJS(cache.data, Omnisearch.options)
|
||||||
@@ -104,7 +103,7 @@ export class Omnisearch {
|
|||||||
*/
|
*/
|
||||||
public async addFromPaths(
|
public async addFromPaths(
|
||||||
paths: string[],
|
paths: string[],
|
||||||
writeToCache: boolean
|
mustWriteToCache: boolean
|
||||||
): Promise<void> {
|
): 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))
|
||||||
@@ -119,13 +118,12 @@ export class Omnisearch {
|
|||||||
// If the user shuts off Obsidian mid-indexing, we at least saved some
|
// If the user shuts off Obsidian mid-indexing, we at least saved some
|
||||||
const chunkedDocs = chunkArray(documents, 500)
|
const chunkedDocs = chunkArray(documents, 500)
|
||||||
for (const docs of chunkedDocs) {
|
for (const docs of chunkedDocs) {
|
||||||
indexingStep.set(IndexingStepType.IndexingFiles)
|
|
||||||
// Update the list of indexed docks
|
// Update the list of indexed docks
|
||||||
docs.forEach(doc => this.indexedDocuments.set(doc.path, doc.mtime))
|
docs.forEach(doc => this.indexedDocuments.set(doc.path, doc.mtime))
|
||||||
// Add docs to minisearch
|
// Add docs to minisearch
|
||||||
await this.minisearch.addAllAsync(docs)
|
await this.minisearch.addAllAsync(docs)
|
||||||
// Save the index
|
// Save the index
|
||||||
if (writeToCache) {
|
if (mustWriteToCache) {
|
||||||
await this.writeToCache()
|
await this.writeToCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,7 +340,6 @@ export class Omnisearch {
|
|||||||
if (Platform.isIosApp) {
|
if (Platform.isIosApp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
indexingStep.set(IndexingStepType.WritingCache)
|
|
||||||
await cacheManager.writeMinisearchCache(
|
await cacheManager.writeMinisearchCache(
|
||||||
this.minisearch,
|
this.minisearch,
|
||||||
this.indexedDocuments
|
this.indexedDocuments
|
||||||
|
|||||||
Reference in New Issue
Block a user