Fix #181 - Making sure that documents have a .path

Though they should...
This commit is contained in:
Simon Cambier
2023-01-17 21:45:35 +01:00
parent 934f1affc4
commit 329aa50daa
2 changed files with 14 additions and 4 deletions

View File

@@ -138,9 +138,17 @@ class CacheManager {
public async addToLiveCache(path: string): Promise<void> {
try {
const doc = await getAndMapIndexedDocument(path)
if (!doc.path) {
console.error(
`Missing .path field in IndexedDocument "${doc.basename}", skipping`
)
return
}
this.documents.set(path, doc)
} catch (e) {
console.warn('Omnisearch: Error while adding to live cache', e)
console.warn(`Omnisearch: Error while adding "${path}" to live cache`, e)
// Shouldn't be needed, but...
this.removeFromLiveCache(path)
}
}