silverbulletmd / silverbullet

The knowledge tinkerer's notebook
https://silverbullet.md
MIT License
2.36k stars 169 forks source link

Check if symlink is a file or directory #758

Closed joekrill closed 7 months ago

joekrill commented 7 months ago

If you have a symlink to a file (not a directory), an error is thrown:

Error: Not a directory (os error 20): readdir '/path/to/the/symlinked/file'
    at async Object.[Symbol.asyncIterator] (ext:deno_fs/30_fs.js:220:19)
    at async walkPreserveSymlinks (file:///Users/joe/projects/silverbullet/common/spaces/disk_space_primitives.ts:160:20)
    at async walkPreserveSymlinks (file:///Users/joe/projects/silverbullet/common/spaces/disk_space_primitives.ts:172:7)
    at async walkPreserveSymlinks (file:///Users/joe/projects/silverbullet/common/spaces/disk_space_primitives.ts:172:7)
    at async DiskSpacePrimitives.fetchFileList (file:///Users/joe/projects/silverbullet/common/spaces/disk_space_primitives.ts:128:22)
    at async AssetBundlePlugSpacePrimitives.fetchFileList (file:///Users/joe/projects/silverbullet/common/spaces/asset_bundle_space_primitives.ts:13:19)
    at async FilteredSpacePrimitives.fetchFileList (file:///Users/joe/projects/silverbullet/common/spaces/filtered_space_primitives.ts:16:13)
    at async PlugSpacePrimitives.fetchFileList (file:///Users/joe/projects/silverbullet/common/spaces/plug_space_primitives.ts:72:19)
    at async EventedSpacePrimitives.fetchFileList (file:///Users/joe/projects/silverbullet/common/spaces/evented_space_primitives.ts:32:25)
    at async ServerSystem.loadPlugs (file:///Users/joe/projects/silverbullet/server/server_system.ts:196:28) {
  code: "ENOTDIR"
}

Looks like this recent fix introduced this bug. This should fix it, I believe. It will also ignore invalid symlinks.

zefhemel commented 7 months ago

Nice, thanks!