brumik / obsidian-ollama-chat

A plugin for chatting with you obsidian notes trough local Ollama LLM instead of Chat GTP.
MIT License
113 stars 6 forks source link

500 error when indexing on Directory creation #10

Closed tcarwash closed 5 months ago

tcarwash commented 5 months ago

I was getting a 500 error from the indexer on directory creation, seems like it doesn't know what to do with a directory path.

I have a rough fix in my own main.js, basically just check to see if the file object passed to the createEvent hook has a children key, if it does it's a directory... don't index it, if it doesn't it's a file and it gets indexed.

async createEvent(file) {                  
    if ('children' in file) {                     
      return;                                                                                                     
    }
    this.requestIndexing("PATCH", file.path);
  }

I'm not sure if you want that fix here, or if you want me to take a look at the indexer. I'm not sure if there's any benefit to indexing directories.

Let me know how/if you want me to proceed. I'm not great with javascript/typescript, so it might take me a bit to get a PR in, but I'm happy to do it.

brumik commented 5 months ago

As far as I see and understand this happens only on new directory creation. I do not see any value trying to index an empty directory, and if you create files in it, it should be indexing them rather.

So if you do not think otherwise I will just exclude create dirs from generating a call to the indexer. WDYT?

brumik commented 5 months ago

I will fix folders here: https://github.com/brumik/ollama-obsidian-indexer/issues/16

brumik commented 5 months ago

The exact issue (on creation) is now fixed in 0.1.2 (released).

https://github.com/brumik/obsidian-ollama-chat/commit/6e74af9b2c67bfc00113eb433b6981f818e213d5