Before using cached file, check it is readable.
Check that we can take a lock. Otherwise disable cache.
fix gh-932
remove duplicate commented line.
Give correct permission when creating the local dataset folder
better error msg.
pep8
Merge pull request #953 from nouiz/cache

Make the cache more resilien to problems and fix local dir permission.