Skip to content

Commit

Permalink
- Add conditional checks for source adapter support when handling fil…
Browse files Browse the repository at this point in the history
…e events

- Verify file extension against available source adapters before processing
- Improve robustness of file creation, renaming, and modification event handlers
  • Loading branch information
brianpetro committed Feb 25, 2025
1 parent c178d22 commit bfd2f3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions smart-environment/obsidian.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,23 @@ export class SmartEnv extends BaseSmartEnv {
const plugin = this.main;
plugin.registerEvent(
plugin.app.vault.on('create', (file) => {
if(file instanceof TFile){
if(file instanceof TFile && this.smart_sources?.source_adapters?.[file.extension]){
this.smart_sources?.init_file_path(file.path);
this.smart_sources?.fs.include_file(file.path);
}
})
);
plugin.registerEvent(
plugin.app.vault.on('rename', (file) => {
if(file instanceof TFile){
if(file instanceof TFile && this.smart_sources?.source_adapters?.[file.extension]){
this.smart_sources?.init_file_path(file.path);
this.smart_sources?.fs.include_file(file.path);
}
})
);
plugin.registerEvent(
plugin.app.vault.on('modify', (file) => {
if(file instanceof TFile){
if(file instanceof TFile && this.smart_sources?.source_adapters?.[file.extension]){
const source = this.smart_sources?.get(file.path);
if(source){
source.queue_import();
Expand Down

0 comments on commit bfd2f3a

Please sign in to comment.