Fix filelisting infinite loops

Related to #11804 but not sure it fixes it entirely
Merge pull request #11887 from makinacorpus/fl

Fix filelisting infinite loops