fix a race condition during directory probing

Resolves-bug: https://github.com/sebhtml/ray/issues/125
Signed-off-by: Sébastien Boisvert <sebastien.boisvert.3@ulaval.ca>