Fix state cache directory not setting proper permissions

Hi,

The cache directory (if missing) was creating with no permissions - so the file save was failing (and made the directory useless). I've added a standard directory set of permissions.

-iain