[CORE] remove usage of Directory#fileExists

This commit removes the usage of #fileExists which has been
deprecated long ago an can be a source of race conditions.
This comment confuses me, is it still going to work well with the write.lock file if we use the primary instead of iterating?