Only hit the database once for directory listings
Summary:
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
Reviewers: anlambert, Reviewers!
Differential Revision: https://forge.softwareheritage.org/D337