check directory is writeable after checking it exists
Merge pull request #170 from hackzilla/cache-check

check directory is writeable after checking it exists