silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.06k stars 146 forks source link

Bug: Symlinked folder content is not indexed on MacOS #740

Closed gorootde closed 4 months ago

gorootde commented 4 months ago

When creating a symlink pointing to a folder containing .md files, that is located outside of my space directory, SB does not discover these files. Not even when running the reindex command manually.

zefhemel commented 4 months ago

I'll check this, to clarify are you running this with docker or directly with Deno?

gorootde commented 4 months ago

Plain deno

gorootde commented 4 months ago

I investigated a little bit and found the root cause:

disk_space_primitives.ts#fetchFileList() uses walk() to build a list of all files in the space. A symlinked directory is resolved to the target path of the symlink. That leads to the fullPath not being inside the space directory.

In the end fixing this would lead to changing the safePath function to accept target paths of all symlinks in the space directory as well. Also almost all SB code assumes that all files are located inside the space path.

zefhemel commented 4 months ago

Ok I'm always a bit scared to do this, but I just replaced the walk call with a custom version that walks symlinks, but preservers their paths. I tested it and for me it seems to work, can you check too? I hope this doesn't regress other features but let's hear if people scream.