directory: Use finite amount of tries for self check
Turn potentially infinite while loops into for loops with finite amount of repetitions. In general 1000 tries should be sufficient, so the chosen amount of 100.000 serves as an upper limit.
See #1290 (closed)
Edited by António Fernandes