Redmine#2753: do not call readlink() on a directory to avoid spurious error message
(cherry picked from commit 5acc1443c0a15eb6bcd900b22e437611becfc017)