Work around a race condition in FilesystemCache directory creation

Explained thouroughly in the comments in the code.