fix symlink handling (#6246)
### Description
Incorrect handling of symlinks caused a race condition in resolving
which causes weird resolving problems when a symlink is present in the
same directory.
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->
Closes WEB-1823