1. Add an option to Server Files repository settings to "Show empty folders" with some explanation that hiding empty folders will cause extra CPU load.
2. Make Server Files use it to call the file browser API differently (eg some parameter like prune=true)
3. Fix file browser api to prune empty folders using direct file table lookups for core stuff and callbacks for modules.