fixes #6435: Race Condition in filesystem cache on prepare dir structure

This should ix the issue #6435
(unit testable only with mocking/wrapping filesystem)

@Ocramius we should have a discussion about fs mocking ;)