Only hit the database once for directory listings
We used to call the database twice for directory listings. We now special-case the empty directory, which allows us to only call the database once, saving one round trip on the most used query.
Test Plan
Unit tests updated
Migrated from D337 (view on Phabricator)