Fixed file watching
This commit is contained in:
14
src/main.ts
14
src/main.ts
@@ -54,8 +54,10 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
// Listeners to keep the search index up-to-date
|
// Listeners to keep the search index up-to-date
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
this.app.vault.on('create', async file => {
|
this.app.vault.on('create', async file => {
|
||||||
cacheManager.addToLiveCache(file.path)
|
if (isFileIndexable(file.path)) {
|
||||||
searchEngine.addFromPaths([file.path], false)
|
await cacheManager.addToLiveCache(file.path)
|
||||||
|
searchEngine.addFromPaths([file.path], false)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
@@ -66,13 +68,15 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
)
|
)
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
this.app.vault.on('modify', async file => {
|
this.app.vault.on('modify', async file => {
|
||||||
cacheManager.addToLiveCache(file.path)
|
if (isFileIndexable(file.path)) {
|
||||||
NotesIndex.markNoteForReindex(file)
|
await cacheManager.addToLiveCache(file.path)
|
||||||
|
NotesIndex.markNoteForReindex(file)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
this.app.vault.on('rename', async (file, oldPath) => {
|
this.app.vault.on('rename', async (file, oldPath) => {
|
||||||
if (file instanceof TFile && isFilePlaintext(file.path)) {
|
if (isFileIndexable(file.path)) {
|
||||||
cacheManager.removeFromLiveCache(oldPath)
|
cacheManager.removeFromLiveCache(oldPath)
|
||||||
cacheManager.addToLiveCache(file.path)
|
cacheManager.addToLiveCache(file.path)
|
||||||
searchEngine.removeFromPaths([oldPath])
|
searchEngine.removeFromPaths([oldPath])
|
||||||
|
|||||||
Reference in New Issue
Block a user