finish PR #5333

The missing bit was listdir being called on files, not just dirs