Change downloaded file permission based on umask
This PR changes the permission of downloaded files to cache, so that the umask is taken into account.

Related to:
- #2157

Fix #5799.

CC: @stas00 
_The documentation is not available anymore as the PR was closed or merged._