Retry download if cached download (or already-downloaded file) have bad hash

This pull request fixes #963.