fix(#245): correctly update embeds on fs events

This commit is contained in:
Simon Cambier
2024-09-27 13:53:30 +02:00
parent 10721601b1
commit 983fa2120b
4 changed files with 58 additions and 26 deletions

View File

@@ -112,7 +112,7 @@ export default class OmnisearchPlugin extends Plugin {
if (this.notesIndexer.isFileIndexable(file.path)) {
logDebug('Indexing new file', file.path)
searchEngine.addFromPaths([file.path])
this.embedsRepository.refreshEmbeds(file.path)
this.embedsRepository.refreshEmbedsForNote(file.path)
}
})
)
@@ -121,7 +121,7 @@ export default class OmnisearchPlugin extends Plugin {
logDebug('Removing file', file.path)
this.cacheManager.removeFromLiveCache(file.path)
searchEngine.removeFromPaths([file.path])
this.embedsRepository.refreshEmbeds(file.path)
this.embedsRepository.removeFile(file.path)
})
)
this.registerEvent(
@@ -129,7 +129,7 @@ export default class OmnisearchPlugin extends Plugin {
if (this.notesIndexer.isFileIndexable(file.path)) {
this.notesIndexer.flagNoteForReindex(file)
}
this.embedsRepository.refreshEmbeds(file.path)
this.embedsRepository.refreshEmbedsForNote(file.path)
})
)
this.registerEvent(
@@ -138,8 +138,11 @@ export default class OmnisearchPlugin extends Plugin {
logDebug('Renaming file', file.path)
this.cacheManager.removeFromLiveCache(oldPath)
await this.cacheManager.addToLiveCache(file.path)
searchEngine.removeFromPaths([oldPath])
await searchEngine.addFromPaths([file.path])
this.embedsRepository.renameFile(oldPath, file.path)
}
})
)