trganda / obsidian-attachment-management

Attachment Management of Obsidian
MIT License
143 stars 8 forks source link

[FR]: Create the directory if it doesn't exist #65

Closed Romc3 closed 9 months ago

Romc3 commented 9 months ago

The plugin seems cannot create the directory if doesn't exist and the attachment location will fallback to obsidian's settings.

For example, if the plugin setting is as follows:

Root folder: assets Attachment path: ${notename} Attachment format ${date}

And the vault is like:

assets/
    note1/
        20230923.jpg
note1.md
note2.md

Pasting attachments to note1.md works as expected, if paste 20230924.jpg, the image file will be located at assets/note1/20230924.jpg.

However, it doesn't work well on note2.md, if paste 20230924.jpg, the directory assets/note2 won't be created, and the attachment will fallback to obsidian's settings.

trganda commented 9 months ago

So, you have paste a same image file in two markdown file?

I have reproduce the problem with step:

  1. same config as you provided.
  2. create note1.md, note2.md in same folder.
  3. screenshot and copy to note1.md, plugin works and renamed the pasted image file in assets/note1/20230924.jpg.
  4. reveal the assets/note1/20230924.jpg in Finder (file exploer of mac)
  5. copy the assets/note1/20230924.jpg from and paste it to note2.md, the ![](assets/note1/20230924.jpg) was added to note2.md by obsidian.

No attachment was created, it's just refer to the exists file.

This is not the problem of plugin, obsidian has processed this operation, since you pasted a file that already exists in vault, no event will be trigger and obsidian will add the link of the file to your notes.

Howerer, this plugin relies on the event to working. This is the reason why the note2 folder was not create.

Romc3 commented 9 months ago

It seems that after reinstalling the whole Obsidian App on iOS and re-configuring the vault, the problem vanishes, and i can't reproduce the bug now. It works as expected, creating directories if there isn't one. Thanks for your patience.